org.kopitubruk.util.json
Interface JSONConfigDefaultsMBean

All Known Implementing Classes:
JSONConfigDefaults

public interface JSONConfigDefaultsMBean

MBean interface for JSONConfigDefaults to expose its methods to view and modify the defaults at run time when this library is used with an MBean server.

Author:
Bill Davidson

Method Summary
 DateFormat addDateParseFormat(String fmtStr)
          Add a date parsing format to the list of date parsing formats used by the parser when encodeDatesAsStrings or encodeDatesAsObjects is true.
 void addReflectClassByName(String className)
          Add the given class to the set of classes to be reflected.
 void clearDateGenFormat()
          Clear date generation format.
 void clearDateParseFormats()
          Clear any date parse formats from the list of formats used by the parser when encodeDatesAsStrings or encodeDatesAsObjects is true.
 void clearNumberFormats()
          Clear any default number formats.
 void clearReflectClasses()
          Clear all reflection classes, disabling all default automatic reflection.
 void clearReflectionCache()
          Clear the reflection cache.
 String getLocaleLanguageTag()
          Get the default locale for new JSONConfig objects in string form.
 int getReflectionPrivacy()
          Get the reflection privacy level.
 int getUndefinedCodePointPolicy()
          Get the default policy for undefined code points.
 int getUnmatchedSurrogatePolicy()
          Get the default policy for unmatched surrogates.
 boolean isAllowReservedWordsInIdentifiers()
          Get the default for allowing reserved words in identifiers.
 boolean isCacheReflectionData()
          Get the the cacheReflectionData policy.
 boolean isDetectDataStructureLoops()
          Get the default detect data structure loops policy.
 boolean isEncodeDatesAsObjects()
          Get the encode dates as objects policy.
 boolean isEncodeDatesAsStrings()
          Get the encode dates as strings policy.
 boolean isEncodeNumericStringsAsNumbers()
          Get the default encode numeric strings as numbers policy.
 boolean isEscapeBadIdentifierCodePoints()
          Get the default escape bad identifier code points policy.
 boolean isEscapeNonAscii()
          Get the default escape non-ASCII policy.
 boolean isEscapeSurrogates()
          Get the default escape surrogates policy.
 boolean isFastStrings()
          Get the fastStrings policy.
 boolean isFullJSONIdentifierCodePoints()
          Get the full JSON identifier code points policy.
 boolean isPassThroughEscapes()
          Get the pass through escapes policy.
 boolean isPreciseNumbers()
          Get the preciseFloatingPoint policy.
 boolean isQuoteIdentifier()
          Get the default quote identifier policy.
 boolean isReflectUnknownObjects()
          Get the reflection of unknown objects policy.
 boolean isSmallNumbers()
          Get the smallNumbers policy.
 boolean isUnEscapeWherePossible()
          The default unEscape policy.
 boolean isUseECMA6()
          Get the default escape ECMAScript 6 code points policy.
 boolean isUsePrimitiveArrays()
          The primitive arrays policy.
 boolean isValidatePropertyNames()
          Get the default validate property names policy.
 String listReflectedClasses()
          Get a string with newline separated list of classes that get reflected.
 void removeReflectClassByName(String className)
          Remove the given class from the set of classes to be reflected.
 void setAllowReservedWordsInIdentifiers(boolean dflt)
          Set default flag for allowing reserved words in identifiers.
 void setCacheReflectionData(boolean dflt)
          If true, then when an object is reflected its reflection data will be cached to improve performance on subsequent reflections of objects of its class.
 void setCodeDefaults()
          Reset all defaults to their original unmodified values.
 DateFormat setDateGenFormat(String fmtStr)
          Set the date format used for date string generation when encodeDatesAsStrings or encodeDatesAsObjects is true.
 void setDetectDataStructureLoops(boolean dflt)
          Set the default flag for detecting data structure loops.
 void setEncodeDatesAsObjects(boolean dflt)
          If true, then Date objects will be encoded as Javascript dates, using new Date(dateString).
 void setEncodeDatesAsStrings(boolean dflt)
          Set the encodeDatesAsStrings policy.
 void setEncodeNumericStringsAsNumbers(boolean dflt)
          Set the default flag for encoding of numeric strings as numbers.
 void setEscapeBadIdentifierCodePoints(boolean dflt)
          If true, then any bad code points in identifiers will be escaped.
 void setEscapeNonAscii(boolean dflt)
          Set the default flag for forcing escaping of non-ASCII characters in strings and identifiers.
 void setEscapeSurrogates(boolean dflt)
          Set the default escapeSurrogates policy.
 void setFastStrings(boolean dflt)
          If true, then string values will be copied to the output with no escaping or validation.
 void setFullJSONIdentifierCodePoints(boolean dflt)
          If true, then the full set of identifier code points permitted by the JSON standard will be allowed instead of the more restrictive set permitted by the ECMAScript standard.
 void setLocaleLanguageTag(String languageTag)
          Set the default locale for new JSONConfig objects to use.
 void setPassThroughEscapes(boolean dflt)
          If true, then escapes in strings will be passed through unchanged.
 void setPreciseNumbers(boolean dflt)
          If true then numbers which are not exactly representable by a 64 bit double precision floating point number will be quoted in the output.
 void setQuoteIdentifier(boolean dflt)
          Set the default flag for forcing quotes on identifiers.
 void setReflectionPrivacy(int dflt)
          Set the privacy level for reflection.
 void setReflectUnknownObjects(boolean dflt)
          Set the reflection encoding policy.
 void setSmallNumbers(boolean dflt)
          If true then JSONParser will attempt to minimize the storage used for all numbers.
 void setUndefinedCodePointPolicy(int dflt)
          Tell JSONUtil what to do by default when it encounters undefined code points in strings and identifiers.
 void setUnEscapeWherePossible(boolean dflt)
          Set default flag for undoing inline escapes in strings.
 void setUnmatchedSurrogatePolicy(int dflt)
          Tell JSONUtil what to do by default when it encounters unmatched surrogates in strings and identifiers.
 void setUseECMA6(boolean dflt)
          If you set this to true, then when JSONUtil generates Unicode escapes, it will use ECMAScript 6 code point escapes if they are shorter than code unit escapes.
 void setUsePrimitiveArrays(boolean dflt)
          If true, then when JSONParser encounters a JSON array of non-null wrappers of primitives and those primitives are all compatible with each other, then instead of an ArrayList of wrappers for those primitives it will create an array of those primitives in order to save memory.
 void setValidatePropertyNames(boolean dflt)
          Set the default flag for validation of property names.
 

Method Detail

setCodeDefaults

void setCodeDefaults()
Reset all defaults to their original unmodified values. This overrides JNDI and previous MBean changes.


getLocaleLanguageTag

String getLocaleLanguageTag()
Get the default locale for new JSONConfig objects in string form.

Returns:
The string form of the default locale.

setLocaleLanguageTag

void setLocaleLanguageTag(String languageTag)
Set the default locale for new JSONConfig objects to use.

Parameters:
languageTag - A language tag used to create a Locale.

clearNumberFormats

void clearNumberFormats()
Clear any default number formats.

Since:
1.4

setDateGenFormat

DateFormat setDateGenFormat(String fmtStr)
Set the date format used for date string generation when encodeDatesAsStrings or encodeDatesAsObjects is true.

Parameters:
fmtStr - passed to the constructor for SimpleDateFormat.SimpleDateFormat(String,Locale) using the result of JSONConfigDefaults.getLocale().
Returns:
the format that is created.
Since:
1.4

clearDateGenFormat

void clearDateGenFormat()
Clear date generation format.

Since:
1.4

addDateParseFormat

DateFormat addDateParseFormat(String fmtStr)
Add a date parsing format to the list of date parsing formats used by the parser when encodeDatesAsStrings or encodeDatesAsObjects is true.

Parameters:
fmtStr - Passed to SimpleDateFormat.SimpleDateFormat(String,Locale) using the result of JSONConfigDefaults.getLocale().
Returns:
The format that gets created.
Since:
1.4

clearDateParseFormats

void clearDateParseFormats()
Clear any date parse formats from the list of formats used by the parser when encodeDatesAsStrings or encodeDatesAsObjects is true.


isValidatePropertyNames

boolean isValidatePropertyNames()
Get the default validate property names policy.

Returns:
The default validate property names policy.

getReflectionPrivacy

int getReflectionPrivacy()
Get the reflection privacy level.

Returns:
the reflection privacy level.
Since:
1.9

setReflectionPrivacy

void setReflectionPrivacy(int dflt)
                          throws MBeanException
Set the privacy level for reflection. Default is ReflectUtil.PRIVATE which includes all fields when reflection is enabled.

Parameters:
dflt - the level to set
Throws:
MBeanException - If the privacy level is not allowed.
Since:
1.9
See Also:
ReflectUtil.PRIVATE, ReflectUtil.PACKAGE, ReflectUtil.PROTECTED, ReflectUtil.PUBLIC

clearReflectClasses

void clearReflectClasses()
Clear all reflection classes, disabling all default automatic reflection.

Since:
1.9

clearReflectionCache

void clearReflectionCache()
Clear the reflection cache.


addReflectClassByName

void addReflectClassByName(String className)
                           throws MBeanException
Add the given class to the set of classes to be reflected.

Parameters:
className - The name of the class suitable for (@link ClassLoader.loadClass(String)}.
Throws:
MBeanException - If there's a problem loading the class.
Since:
1.9

removeReflectClassByName

void removeReflectClassByName(String className)
                              throws MBeanException
Remove the given class from the set of classes to be reflected.

Parameters:
className - The name of the class suitable for (@link ClassLoader.loadClass(String)}.
Throws:
MBeanException - If there's a problem loading the class.
Since:
1.9

listReflectedClasses

String listReflectedClasses()
Get a string with newline separated list of classes that get reflected.

Returns:
A string with newline separated list of classes that get reflected.
Since:
1.9

getUnmatchedSurrogatePolicy

int getUnmatchedSurrogatePolicy()
Get the default policy for unmatched surrogates.

Returns:
the default policy for unmatched surrogates.

setUnmatchedSurrogatePolicy

void setUnmatchedSurrogatePolicy(int dflt)
Tell JSONUtil what to do by default when it encounters unmatched surrogates in strings and identifiers. The permitted values are: Any other value will be ignored.

Parameters:
dflt - the default unmatchedSurrogatePolicy to set

getUndefinedCodePointPolicy

int getUndefinedCodePointPolicy()
Get the default policy for undefined code points.

Returns:
the policy for undefined code points.

setUndefinedCodePointPolicy

void setUndefinedCodePointPolicy(int dflt)
Tell JSONUtil what to do by default when it encounters undefined code points in strings and identifiers. The permitted values are: Any other value will be ignored.

Parameters:
dflt - the default undefinedCodePointPolicy to set

setValidatePropertyNames

void setValidatePropertyNames(boolean dflt)
Set the default flag for validation of property names. This will affect all new JSONConfig objects created after this call within the same class loader.

Parameters:
dflt - If true, then property names will be validated by default.

isDetectDataStructureLoops

boolean isDetectDataStructureLoops()
Get the default detect data structure loops policy. Accessible via MBean server.

Returns:
The default detect data structure loops policy.

setDetectDataStructureLoops

void setDetectDataStructureLoops(boolean dflt)
Set the default flag for detecting data structure loops. If true, then if a loop in a data structure is found then a DataStructureLoopException will be thrown. This will affect all new JSONConfig objects created after this call within the same class loader.

Parameters:
dflt - If true, then the code will detect loops in data structures.

isEscapeBadIdentifierCodePoints

boolean isEscapeBadIdentifierCodePoints()
Get the default escape bad identifier code points policy.

Returns:
The default escape bad identifier code points policy.

setEscapeBadIdentifierCodePoints

void setEscapeBadIdentifierCodePoints(boolean dflt)
If true, then any bad code points in identifiers will be escaped. Default is false.

Parameters:
dflt - if true, then any bad code points in identifiers will be escaped.

isFullJSONIdentifierCodePoints

boolean isFullJSONIdentifierCodePoints()
Get the full JSON identifier code points policy.

Returns:
the fullJSONIdentifierCodePoints

setFullJSONIdentifierCodePoints

void setFullJSONIdentifierCodePoints(boolean dflt)
If true, then the full set of identifier code points permitted by the JSON standard will be allowed instead of the more restrictive set permitted by the ECMAScript standard. Use of characters not permitted by the ECMAScript standard will cause an error if parsed by Javascript eval().

Parameters:
dflt - If true, then allow all code points permitted by the JSON standard in identifiers.

isFastStrings

boolean isFastStrings()
Get the fastStrings policy.

Returns:
the fastStrings policy

setFastStrings

void setFastStrings(boolean dflt)
If true, then string values will be copied to the output with no escaping or validation.

Only use this if you know that you have no characters in the range U+0000-U+001F or backslash or forward slash or double quote in your strings. If you want your JSON to be parsable by Javascript eval() then you also need to make sure that you don't have U+2028 (line separator) or U+2029 (paragraph separator).

That said, if you are encoding a lot of large strings, this can improve performance by eliminating the check for characters that need to be escaped.

Parameters:
dflt - If true, then strings will be copied as is with no escaping or validation.

isEncodeNumericStringsAsNumbers

boolean isEncodeNumericStringsAsNumbers()
Get the default encode numeric strings as numbers policy.

Returns:
The default encode numeric strings as numbers policy.

setEncodeNumericStringsAsNumbers

void setEncodeNumericStringsAsNumbers(boolean dflt)
Set the default flag for encoding of numeric strings as numbers.

Parameters:
dflt - If true, then strings that look like valid JSON numbers will be encoded as numbers.

isEscapeNonAscii

boolean isEscapeNonAscii()
Get the default escape non-ASCII policy.

Returns:
The default quote non-ASCII policy.

setEscapeNonAscii

void setEscapeNonAscii(boolean dflt)
Set the default flag for forcing escaping of non-ASCII characters in strings and identifiers. If true, then escapeSurrogates will be forced to false. This will affect all new JSONConfig objects created after this call within the same class loader.

Parameters:
dflt - If true, then all non-ASCII will be Unicode escaped.

isUnEscapeWherePossible

boolean isUnEscapeWherePossible()
The default unEscape policy.

Returns:
the unEscape policy.

setUnEscapeWherePossible

void setUnEscapeWherePossible(boolean dflt)
Set default flag for undoing inline escapes in strings.

Parameters:
dflt - If true then where possible, undo inline escapes in strings.

isEscapeSurrogates

boolean isEscapeSurrogates()
Get the default escape surrogates policy.

Returns:
the escape surrogates policy.

setEscapeSurrogates

void setEscapeSurrogates(boolean dflt)
Set the default escapeSurrogates policy.

Parameters:
dflt - If true, then surrogates will be escaped in strings and identifiers and escapeNonAscii will be forced to false.

isPassThroughEscapes

boolean isPassThroughEscapes()
Get the pass through escapes policy.

Accessible via MBean server.

Returns:
The pass through escapes policy.

setPassThroughEscapes

void setPassThroughEscapes(boolean dflt)
If true, then escapes in strings will be passed through unchanged. If false, then the backslash that starts the escape will be escaped.

Accessible via MBean server.

Parameters:
dflt - If true, then pass escapes through.

isEncodeDatesAsStrings

boolean isEncodeDatesAsStrings()
Get the encode dates as strings policy.

Returns:
the encodeDatesAsStrings policy.

setEncodeDatesAsStrings

void setEncodeDatesAsStrings(boolean dflt)
Set the encodeDatesAsStrings policy. If you set this to true, then encodeDatesAsObjects will be set to false.

Accessible via MBean server.

Parameters:
dflt - If true, then Date objects will be encoded as ISO 8601 date strings or a custom date format if you have called JSONConfigDefaults.setDateGenFormat(DateFormat).

isReflectUnknownObjects

boolean isReflectUnknownObjects()
Get the reflection of unknown objects policy.

Returns:
the reflectUnknownObjects policy.
Since:
1.9

setReflectUnknownObjects

void setReflectUnknownObjects(boolean dflt)
Set the reflection encoding policy. If true, then any time that an unknown object is encountered, this package will attempt to use reflection to encode it. Default is false. When false, then unknown objects will have their toString() method called.

Parameters:
dflt - If true, then attempt to use reflection to encode objects which are otherwise unknown.
Since:
1.9

isPreciseNumbers

boolean isPreciseNumbers()
Get the preciseFloatingPoint policy.

Returns:
The preciseFloatingPoint policy.
Since:
1.9

setPreciseNumbers

void setPreciseNumbers(boolean dflt)
If true then numbers which are not exactly representable by a 64 bit double precision floating point number will be quoted in the output. If false, then they will be unquoted, and precision in such will likely be lost in the interpreter.

Parameters:
dflt - If true then quote numbers that lose precision in 64-bit floating point.
Since:
1.9

isSmallNumbers

boolean isSmallNumbers()
Get the smallNumbers policy.

Returns:
The smallNumbers policy.
Since:
1.9

setSmallNumbers

void setSmallNumbers(boolean dflt)
If true then JSONParser will attempt to minimize the storage used for all numbers. Decimal numbers will be reduced to floats instead of doubles if it can done without losing precision. Integer numbers will be reduced from long to int or short or byte if they fit.

Parameters:
dflt - If true then numbers will be made to use as little memory as possible.
Since:
1.9

isUsePrimitiveArrays

boolean isUsePrimitiveArrays()
The primitive arrays policy.

Returns:
the usePrimitiveArrays policy.
Since:
1.9

setUsePrimitiveArrays

void setUsePrimitiveArrays(boolean dflt)
If true, then when JSONParser encounters a JSON array of non-null wrappers of primitives and those primitives are all compatible with each other, then instead of an ArrayList of wrappers for those primitives it will create an array of those primitives in order to save memory.

This works for booleans and numbers. It will also convert an array of single character strings into an array of chars. Arrays of numbers will attempt to use the least complex type that does not lose information. You could easily end up with an array of bytes if all of your numbers are integers in the range -128 to 127. This option is meant to save as much memory as possible.

Parameters:
dflt - if true, then the parser will create arrays of primitives as applicable.
Since:
1.9

isCacheReflectionData

boolean isCacheReflectionData()
Get the the cacheReflectionData policy.

Returns:
the cacheReflectionData policy.
Since:
1.9

setCacheReflectionData

void setCacheReflectionData(boolean dflt)
If true, then when an object is reflected its reflection data will be cached to improve performance on subsequent reflections of objects of its class.

Parameters:
dflt - if true, then cache reflection data.
Since:
1.9

isQuoteIdentifier

boolean isQuoteIdentifier()
Get the default quote identifier policy.

Returns:
The default quote identifier policy.

setQuoteIdentifier

void setQuoteIdentifier(boolean dflt)
Set the default flag for forcing quotes on identifiers. This will affect all new JSONConfig objects created after this call within the same class loader.

Accessible via MBean server.

Parameters:
dflt - If true, then all identifiers will be quoted.

isUseECMA6

boolean isUseECMA6()
Get the default escape ECMAScript 6 code points policy.

Returns:
The default escape ECMAScript 6 code points policy.

setUseECMA6

void setUseECMA6(boolean dflt)
If you set this to true, then when JSONUtil generates Unicode escapes, it will use ECMAScript 6 code point escapes if they are shorter than code unit escapes. This is not standard JSON and not yet widely supported by Javascript interpreters. It also allows identifiers to have letter numbers in addition to other letters. Default is false.

Parameters:
dflt - If true, use EMCAScript 6 code point escapes and allow ECMAScript 6 identifier character set.

isAllowReservedWordsInIdentifiers

boolean isAllowReservedWordsInIdentifiers()
Get the default for allowing reserved words in identifiers.

Returns:
the reserverd words in identifiers policy.

setAllowReservedWordsInIdentifiers

void setAllowReservedWordsInIdentifiers(boolean dflt)
Set default flag for allowing reserved words in identifiers.

Parameters:
dflt - If true, then reserved words will be allowed in identifiers.

isEncodeDatesAsObjects

boolean isEncodeDatesAsObjects()
Get the encode dates as objects policy.

Returns:
the encodeDatesAsObjects policy.

setEncodeDatesAsObjects

void setEncodeDatesAsObjects(boolean dflt)
If true, then Date objects will be encoded as Javascript dates, using new Date(dateString). If you set this to true, then encodeDatesAsStrings will be set to false.

Parameters:
dflt - If true, then Date objects will be encoded as Javascript dates.


Copyright © 2016. All rights reserved.