public class DfMapStyle extends Object
e.g. map-string as one liner
map:{key1=value1;key2=list:{value21;value22;value23},key3=map:{key31=value31}}
e.g. map-string as formatted
map:{
; key1 = value1
; key2 = list:{ value21 ; value22 ; value23 }
; key3 = map:{ key31 ; value31 }
}
e.g. list-string
list:{key1=value1,key2=list:{value21,value22,value23},key3=map:{key31=value31}}
Detail Specification:
o all elements are trimmed e.g. map:{ sea = land } to {sea=land}
o empty or null value is treated as null e.g. map:{ sea = ; land = null } to both null
o empty elements are ignored e.g. list:{ ; sea ; ; land } to [sea, land]
o can escape control marks e.g. '{', ';' by escape character '\'
o but cannot escape escape character itself
o basically cannot change control mark, but you can override...
o can check duplicate entry of map key by option checkDuplicateEntry()
o can print as one liner by option printOneLiner()
o non-thread-safe, uses temporary variables
o but can recycle in same thread
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected String |
_beginBrace
The control mark of begin-brace. e.g. "{" (NotNull)
|
protected boolean |
_checkDuplicateEntry
Does it check duplicate entry of map for generation?
|
protected int |
_currentRemainderIndex
The current index of remainder string for parsing process.
|
protected String |
_elementDelimiter
The control mark of element-delimiter. e.g. ";" (NotNull)
|
protected String |
_endBrace
The control mark of end-brace. e.g. "}" (NotNull)
|
protected String |
_escapeChar
The escape character for control marks. "\\" (NotNull)
|
protected String |
_listingBeginBrace
The cached expression of begin-brace for list. e.g.
|
protected String |
_listPrefix
The object prefix of list. e.g.
|
protected String |
_mappingBeginBrace
The cached expression of begin-brace for map. e.g.
|
protected String |
_mapPrefix
The object prefix of map. e.g.
|
protected boolean |
_printOneLiner
Does it print as one-liner for building?
|
protected String |
_remainderString
The whole map-string of logical remainder as temporary variable for parsing process.
|
protected String |
_valueEqual
The control mark of value-equal. e.g. "=" (NotNull)
|
static String |
BEGIN_BRACE
The control mark of begin-brace.
|
static String |
ELEMENT_DELIMITER
The control mark of element-delimiter.
|
static String |
END_BRACE
The control mark of end-brace.
|
protected static String |
ESCAPE_CHAR
The escape character for control marks.
|
protected static String |
ESCAPED_ESCAPE_MARK
The temporary mark of escaped escape character.
|
static String |
LIST_PREFIX
The object prefix of list.
|
static String |
MAP_PREFIX
The object prefix of map.
|
static String |
VALUE_EQUAL
The control mark of value-equal.
|
| 修飾子 | コンストラクタと説明 |
|---|---|
|
DfMapStyle()
Constructor for settings as default.
|
protected |
DfMapStyle(String mapPrefix,
String listPrefix,
String beginBrace,
String endBrace,
String elementDelimiter,
String valueEqual,
String escapeChar) |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected void |
assertDuplicateEntryInMap(Map<String,Object> currentMap,
String key,
Object element) |
protected void |
assertFirstListString() |
protected void |
assertFirstMapString() |
protected void |
assertLastRemainderAsList(List<Object> generatedList) |
protected void |
assertLastRemainderAsMap(Map<String,Object> generatedMap) |
protected void |
assertListStringEndBraceIndex(int endBraceIndex,
List<?> makingList) |
protected void |
assertMapStringEndBraceIndex(int endBraceIndex,
Map<String,Object> makingMap) |
protected void |
assertMapStringEqualIndex(int valueEqualIndex,
Map<String,Object> currentMap) |
protected void |
assertObjectNotNull(String variableName,
Object value) |
protected void |
assertRemovingPrefix(String prefixString) |
protected void |
assertStringNotNullAndNotTrimmedEmpty(String variableName,
String value) |
protected void |
beginRemainder(String mapString) |
protected void |
buildListString(StringBuilder sb,
List<? extends Object> list,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected void |
buildMapString(StringBuilder sb,
Map<String,Object> map,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
DfMapStyle |
checkDuplicateEntry()
Check duplicate entry of map for generation.
|
protected boolean |
closeAfterParseNestMapList()
Close after parse nest map list.
|
protected void |
closeByEndBraceIndex(int endBraceIndex)
Close by end-brace index.
|
protected String |
convertToEscapedMark(String mark) |
protected String |
convertToLengthSpace(String value) |
protected String |
cut(String str,
int length,
String suffix) |
protected String |
deriveNextIndentOfBuildingMapString(boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected void |
doBuildListStringBegin(StringBuilder sb,
List<? extends Object> list,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected void |
doBuildListStringCurrentElement(StringBuilder sb,
boolean printOneLiner,
String previousIndent,
String currentIndent,
int index,
Object value) |
protected void |
doBuildListStringEnd(StringBuilder sb,
List<? extends Object> list,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected void |
doBuildMapStringBegin(StringBuilder sb,
Map<String,Object> map,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected void |
doBuildMapStringCurrentEntry(StringBuilder sb,
boolean printOneLiner,
String previousIndent,
String currentIndent,
int index,
String key,
Object value) |
protected void |
doBuildMapStringEnd(StringBuilder sb,
Map<String,Object> map,
boolean printOneLiner,
String previousIndent,
String currentIndent) |
protected String |
doEscapeControlMark(Object value,
boolean ignoreEqual) |
protected String |
doFilterParsedMapListNullExpression(String filtered) |
protected void |
doRemovePrefix(String prefixString)
Remove prefix as mark.
|
protected String |
doUnescapeControlMark(String value,
boolean ignoreEqual) |
protected void |
endRemainder() |
protected boolean |
endsWithEndBrace()
Does it end with end-brace?
|
String |
escapeControlMarkAsList(Object value)
Escape control marks as plain string in the list value.
|
String |
escapeControlMarkAsMap(Object value)
Escape control marks as plain string in the map key and value.
|
protected String |
filterParsedListValue(String value) |
protected String |
filterParsedMapKey(String value) |
protected String |
filterParsedMapValue(String value) |
protected int |
findIndexOfControlMark(String controlMark) |
List<Object> |
fromListString(String listString)
Convert to map object from list-string.
|
Map<String,Object> |
fromMapString(String mapString)
Convert to map object from the map-string.
|
protected String |
generally_calculateNextIndent(String previousIndent,
String currentIndent) |
protected boolean |
generally_endsWith(String str,
String suffix) |
protected int |
generally_indexOfNonTrimmedChar(String str,
int offsetIndex) |
protected int |
generally_lastIndexOfNonTrimmedChar(String str) |
protected String |
generally_replace(String str,
String fromStr,
String toStr) |
protected int |
indexOfDelimiter() |
protected int |
indexOfEndBrace() |
protected int |
indexOfEqual() |
protected int |
indexOfRemainderNonTrimmedChar() |
protected int |
indexOfStartBrace() |
boolean |
isCheckDuplicateEntry() |
protected boolean |
isEscapeCharEscape() |
protected boolean |
isIgnoreEqualAsEscapeControlMarkInList() |
protected boolean |
isIgnoreEqualAsUnescapeControlMarkInList() |
boolean |
isPrintOneLiner() |
protected boolean |
isRemainderOver() |
protected int |
lengthRemainder() |
protected String |
ln() |
protected void |
ltrimRemainder() |
List<Object> |
newObjectList()
New object-type list.
|
Map<String,Object> |
newStringObjectMap()
New string-object map.
|
protected void |
parseListString(List<Object> currentList)
Parse the current remainder string as list.
|
protected void |
parseMapString(Map<String,Object> currentMap)
Parse the current remainder string as map.
|
protected boolean |
prepareLoopBeginning()
prepare loop beginning.
|
DfMapStyle |
printOneLiner()
Print as one liner for building.
|
protected void |
registerToMap(Map<String,Object> currentMap,
String key,
Object element) |
protected void |
removePrefixAllDelimiter()
Remove prefix and all delimiters.
|
protected void |
removePrefixDelimiter()
Remove prefix delimiter.
|
protected void |
removePrefixEndBrace()
Remove prefix end-brace.
|
protected void |
removePrefixListingBeginBrace()
Remove prefix list-prefix and begin-brace.
|
protected void |
removePrefixMapingBeginBrace()
Remove prefix map-prefix and begin-brace.
|
protected void |
removePrefixTargetIndexPlus(int index,
int plusCount)
Remove prefix by the index and plus count.
|
protected Map<String,Object> |
resolvePotentialMapOfBuildingMapString(Object value) |
protected void |
setupMessageRemainderString(ExceptionMessageBuilder br) |
protected List<Object> |
setupNestList(List<Object> currentList)
Set up new-created nest list as element of the current list.
|
protected List<Object> |
setupNestList(Map<String,Object> currentMap,
String mapKey)
Set up new-created nest list as element of the current map.
|
protected Map<String,Object> |
setupNestMap(List<Object> currentList)
Set up new-created nest map as element of the current list.
|
protected Map<String,Object> |
setupNestMap(Map<String,Object> currentMap,
String mapKey)
Set up new-created nest map as element of the current map.
|
protected boolean |
startsWithDelimiter()
Does it start with the delimiter?
|
protected boolean |
startsWithEndBrace()
Does it start with end-brace?
|
protected boolean |
startsWithListBeginBrace()
Does it start with the list-prefix?
|
protected boolean |
startsWithMapBeginBrace()
Does it start with the map-prefix?
|
protected boolean |
startsWithPrefix(String prefix) |
protected String |
substringRemainderFront(int endIndex) |
protected String |
substringRemainderScope(int beginIndex,
int endIndex) |
protected void |
throwDfListStringDifferentCountBracesException(int beginCount,
int endCount) |
protected void |
throwDfListStringEndBraceFailureException(String notice,
int endBraceIndex,
List<?> makingList) |
protected void |
throwDfListStringUnneededStringFoundException(List<Object> generatedList) |
protected void |
throwDfMapDuplicateEntryException(Map<String,Object> currentMap,
String key,
Object element) |
protected void |
throwDfMapRemovingPrefixFailureException(String notice,
String prefixString) |
protected void |
throwDfMapStringBasicFailureException(String notice) |
protected void |
throwDfMapStringDifferentCountBracesException(int beginCount,
int endCount) |
protected void |
throwDfMapStringEndBraceFailureException(String notice,
int endBraceIndex,
Map<String,Object> currentMap) |
protected void |
throwDfMapStringUnneededStringFoundException(Map<String,Object> generatedMap) |
protected void |
throwDfMapValueEqualFailureException(String notice,
int valueEqualIndex,
Map<String,Object> currentMap) |
protected void |
throwListStringBasicFailureException(String notice) |
String |
toListString(List<? extends Object> list)
Convert to list-string from the list object.
|
String |
toMapString(Map<String,? extends Object> map)
Convert to map-string from the map object.
|
String |
unescapeControlMarkAsList(String value)
Unescape control marks as plain string in the list value.
|
String |
unescapeControlMarkAsMap(String value)
Unescape control marks as plain string in the map key and value.
|
public static final String ELEMENT_DELIMITER
protected static final String ESCAPE_CHAR
protected static final String ESCAPED_ESCAPE_MARK
protected final String _mapPrefix
protected final String _listPrefix
protected final String _beginBrace
protected final String _endBrace
protected final String _elementDelimiter
protected final String _valueEqual
protected final String _escapeChar
protected final String _mappingBeginBrace
protected final String _listingBeginBrace
protected String _remainderString
protected int _currentRemainderIndex
protected boolean _checkDuplicateEntry
protected boolean _printOneLiner
public DfMapStyle checkDuplicateEntry()
public DfMapStyle printOneLiner()
public String toMapString(Map<String,? extends Object> map)
map - The map object that has string keys. (NotNull, EmptyAllowed)protected void buildMapString(StringBuilder sb, Map<String,Object> map, boolean printOneLiner, String previousIndent, String currentIndent)
protected void doBuildMapStringBegin(StringBuilder sb, Map<String,Object> map, boolean printOneLiner, String previousIndent, String currentIndent)
protected void doBuildMapStringCurrentEntry(StringBuilder sb, boolean printOneLiner, String previousIndent, String currentIndent, int index, String key, Object value)
protected void doBuildMapStringEnd(StringBuilder sb, Map<String,Object> map, boolean printOneLiner, String previousIndent, String currentIndent)
public String toListString(List<? extends Object> list)
list - The list object that has object elements. (NotNull, EmptyAllowed)protected void buildListString(StringBuilder sb, List<? extends Object> list, boolean printOneLiner, String previousIndent, String currentIndent)
protected void doBuildListStringBegin(StringBuilder sb, List<? extends Object> list, boolean printOneLiner, String previousIndent, String currentIndent)
protected void doBuildListStringCurrentElement(StringBuilder sb, boolean printOneLiner, String previousIndent, String currentIndent, int index, Object value)
protected void doBuildListStringEnd(StringBuilder sb, List<? extends Object> list, boolean printOneLiner, String previousIndent, String currentIndent)
protected String deriveNextIndentOfBuildingMapString(boolean printOneLiner, String previousIndent, String currentIndent)
protected Map<String,Object> resolvePotentialMapOfBuildingMapString(Object value)
public Map<String,Object> fromMapString(String mapString)
mapString - The string as map expression. (NotNull, NotEmpty)public List<Object> fromListString(String listString)
listString - The string as list expression. (NotNull, NotEmpty)protected void parseMapString(Map<String,Object> currentMap)
currentMap - The current map made by parse process. (NotNull)protected void parseListString(List<Object> currentList)
currentList - The current list made by parse process. (NotNull)protected boolean prepareLoopBeginning()
protected boolean closeAfterParseNestMapList()
protected void closeByEndBraceIndex(int endBraceIndex)
endBraceIndex - The index of end-brace. (NotMinus)protected int indexOfStartBrace()
protected int indexOfEndBrace()
protected int indexOfDelimiter()
protected int indexOfEqual()
protected int findIndexOfControlMark(String controlMark)
protected void removePrefixAllDelimiter()
protected void removePrefixMapingBeginBrace()
protected void removePrefixListingBeginBrace()
protected void removePrefixEndBrace()
protected void removePrefixDelimiter()
protected void doRemovePrefix(String prefixString)
prefixString - The string for prefix. (NotNull)protected void removePrefixTargetIndexPlus(int index,
int plusCount)
index - The base index. (NotMinus)plusCount - The plus count for index. (NotMinus)protected boolean startsWithMapBeginBrace()
protected boolean startsWithListBeginBrace()
protected boolean startsWithDelimiter()
protected boolean startsWithEndBrace()
protected boolean startsWithPrefix(String prefix)
protected boolean endsWithEndBrace()
protected void registerToMap(Map<String,Object> currentMap, String key, Object element)
protected void assertDuplicateEntryInMap(Map<String,Object> currentMap, String key, Object element)
protected void throwDfMapDuplicateEntryException(Map<String,Object> currentMap, String key, Object element)
protected Map<String,Object> setupNestMap(Map<String,Object> currentMap, String mapKey)
currentMap - the current map to set up. (NotNull)mapKey - The key of nest map. (NotNull)protected Map<String,Object> setupNestMap(List<Object> currentList)
currentList - the current list to set up. (NotNull)protected List<Object> setupNestList(Map<String,Object> currentMap, String mapKey)
currentMap - the current map to set up. (NotNull)mapKey - The key of nest map. (NotNull)protected List<Object> setupNestList(List<Object> currentList)
currentList - the current map to set up. (NotNull)protected String doFilterParsedMapListNullExpression(String filtered)
public Map<String,Object> newStringObjectMap()
public List<Object> newObjectList()
public String escapeControlMarkAsMap(Object value)
value - The value, might contain control marks. (NullAllowed: if null, return null)public String escapeControlMarkAsList(Object value)
value - The value, might contain control marks. (NullAllowed: if null, return null)protected boolean isIgnoreEqualAsEscapeControlMarkInList()
public String unescapeControlMarkAsMap(String value)
value - The value, might contain escaped control marks. (NullAllowed: if null, return null)public String unescapeControlMarkAsList(String value)
value - The value, might contain escaped control marks. (NullAllowed: if null, return null)protected boolean isIgnoreEqualAsUnescapeControlMarkInList()
protected boolean isEscapeCharEscape()
protected void assertFirstMapString()
protected void throwDfMapStringBasicFailureException(String notice)
protected void throwDfMapStringDifferentCountBracesException(int beginCount,
int endCount)
protected void assertFirstListString()
protected void throwListStringBasicFailureException(String notice)
protected void throwDfListStringDifferentCountBracesException(int beginCount,
int endCount)
protected void assertMapStringEqualIndex(int valueEqualIndex,
Map<String,Object> currentMap)
protected void throwDfMapValueEqualFailureException(String notice, int valueEqualIndex, Map<String,Object> currentMap)
protected void assertMapStringEndBraceIndex(int endBraceIndex,
Map<String,Object> makingMap)
protected void throwDfMapStringEndBraceFailureException(String notice, int endBraceIndex, Map<String,Object> currentMap)
protected void assertListStringEndBraceIndex(int endBraceIndex,
List<?> makingList)
protected void throwDfListStringEndBraceFailureException(String notice, int endBraceIndex, List<?> makingList)
protected void assertRemovingPrefix(String prefixString)
protected void throwDfMapRemovingPrefixFailureException(String notice, String prefixString)
protected void throwDfMapStringUnneededStringFoundException(Map<String,Object> generatedMap)
protected void throwDfListStringUnneededStringFoundException(List<Object> generatedList)
protected void setupMessageRemainderString(ExceptionMessageBuilder br)
protected void beginRemainder(String mapString)
protected void endRemainder()
protected int indexOfRemainderNonTrimmedChar()
protected boolean isRemainderOver()
protected int lengthRemainder()
protected void ltrimRemainder()
protected String substringRemainderFront(int endIndex)
protected String substringRemainderScope(int beginIndex, int endIndex)
protected int generally_indexOfNonTrimmedChar(String str, int offsetIndex)
protected int generally_lastIndexOfNonTrimmedChar(String str)
protected String generally_calculateNextIndent(String previousIndent, String currentIndent)
protected String ln()
protected void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value)
public boolean isCheckDuplicateEntry()
public boolean isPrintOneLiner()
Copyright © 2014–2019 The DBFlute Project. All rights reserved.