Package org.aoju.bus.setting.magic
Class AbstractElement
java.lang.Object
org.aoju.bus.setting.magic.AbstractElement
- All Implemented Interfaces:
Serializable,CharSequence,IniElement
- Direct Known Subclasses:
IniCommentImpl,IniPropertyImpl,IniSectionImpl
an abstract class for
IniElement.- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionprotected voidchangeValue(String newValue) change value.charcharAt(int index) Returns thecharvalue at the specified index.voidclear comment (if exists).there may be comments at the end of each element.get the original string.intlength()Returns the length of this character sequence.intline()the line number where you are.protected voidsetOriginalValue(String newOriginalValue) change this element's value.subSequence(int start, int end) Returns aCharSequencethat is a subsequence of this sequence.Get complete information.liketoString(), without comment value(if exists).toString()Default isoriginalValue.toString()protected static Stringtrim a valuevalue()this element's value.protected abstract StringvalueChanged(String newValue) If thevaluechanged, change the originalValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmptyMethods inherited from interface org.aoju.bus.setting.magic.IniElement
getCommentOptional, isComment, isProperty, isSection, setValue
-
Method Details
-
trim
trim a value- Parameters:
value- char sequence value- Returns:
- trimmed value
-
valueChanged
If thevaluechanged, change the originalValue- Parameters:
newValue- whenvaluechanges, likesetValue(String)orIniElement.setValue(java.util.function.Function)- Returns:
- new originalValue
-
value
this element's value. maybe a
toStringvalue likecomment, a property's value likepropertyor a title value likesection.- Specified by:
valuein interfaceIniElement- Returns:
- some value
-
changeValue
change value.- Parameters:
newValue- a new value
-
setValue
change this element's value. if you want to DIY how to set value, Recommended to coverchangeValue(String)instead ofsetValue(String)- Specified by:
setValuein interfaceIniElement- Parameters:
newValue- a new value- Returns:
- old value
- See Also:
-
toString
Default isoriginalValue.toString()- Specified by:
toStringin interfaceCharSequence- Specified by:
toStringin interfaceIniElement- Overrides:
toStringin classObject- Returns:
- string value
-
getOriginalValue
get the original string.- Specified by:
getOriginalValuein interfaceIniElement- Returns:
- original string value.
-
setOriginalValue
-
getComment
Description copied from interface:IniElementthere may be comments at the end of each element. or null. if this element is comment, return null. so, nullable, or seeIniElement.getCommentOptional().- Specified by:
getCommentin interfaceIniElement- Returns:
- comment end of the element or null. if element, return null.
- See Also:
-
clearComment
public void clearComment()clear comment (if exists).- Specified by:
clearCommentin interfaceIniElement
-
toNoCommentString
liketoString(), without comment value(if exists).- Specified by:
toNoCommentStringin interfaceIniElement- Returns:
- to string value without comment value.
-
toCompleteString
Get complete information. Take sec as an example:section.toString() + all properties.toString() + comment.toString()In general, it is about the same astoString().- Specified by:
toCompleteStringin interfaceIniElement- Returns:
- the string
-
line
public int line()the line number where you are.- Specified by:
linein interfaceIniElement- Returns:
- line number.
-
length
public int length()Returns the length of this character sequence. The length is the number of 16-bitchars in the sequence.- Specified by:
lengthin interfaceCharSequence- Returns:
- the number of
chars in this sequence
-
charAt
public char charAt(int index) Returns thecharvalue at the specified index. An index ranges from zero to length() - 1. The firstcharvalue of the sequence is at index zero, the next at index one, and so on, as for array indexing.If the
charvalue specified by the index is a surrogate, the surrogate value is returned.- Specified by:
charAtin interfaceCharSequence- Parameters:
index- the index of thecharvalue to be returned- Returns:
- the specified
charvalue - Throws:
IndexOutOfBoundsException- if the index argument is negative or not less than length()
-
subSequence
Returns aCharSequencethat is a subsequence of this sequence. The subsequence starts with thecharvalue at the specified index and ends with thecharvalue at index end - 1. The length (inchars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.- Specified by:
subSequencein interfaceCharSequence- Parameters:
start- the start index, inclusiveend- the end index, exclusive- Returns:
- the specified subsequence
- Throws:
IndexOutOfBoundsException- if start or end are negative, if end is greater than length(), or if start is greater than end
-