Class EncodingInfo
- java.lang.Object
-
- org.hortonmachine.gears.utils.style.sld.EncodingInfo
-
public class EncodingInfo extends Object
Xerces'getEncodingName()method oforg.apache.xerces.impl.XMLEntityManager) returns an array with name of encoding scheme and endianness. I decided to create a separate class incapsulating encoding metadata. The may idea behind this is the fact that we will most probably need to save this info somewhere and use it later when writing the response. Beside that, using class makes related code more clear.
-
-
Constructor Summary
Constructors Constructor Description EncodingInfo()Non-arg constructor to use in a few cases when you need a blank instance ofEncodingInfo.EncodingInfo(String encoding, Boolean isBigEndian)Constructor that takes name of the encoding scheme and endianness - results of autodetection ingetEncodingName.EncodingInfo(String encoding, Boolean isBigEndian, boolean hasBOM)Constructor that takes name of the encoding scheme and endianness - results of autodetection ingetEncodingName().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyFrom(EncodingInfo encInfo)Copies property values from anotherEncodingInfoinstance.StringgetEncoding()Returns current encoding scheme (or charset).booleanhasBOM()Accessor forfHasBOM.BooleanisBigEndian()Accessor forfIsBigEndian.voidsetEncoding(String encoding)Sets new value of stored encoding (charset?) name.StringtoString()Returns current state of this instance in human-readable form.
-
-
-
Constructor Detail
-
EncodingInfo
public EncodingInfo()
Non-arg constructor to use in a few cases when you need a blank instance ofEncodingInfo. It cant' be used right after creation and should be populated first via either setters or specific charset detection methods.
-
EncodingInfo
public EncodingInfo(String encoding, Boolean isBigEndian)
Constructor that takes name of the encoding scheme and endianness - results of autodetection ingetEncodingName. BOM is considered missing if object is constructed this way.- Parameters:
encoding- Name of the autodetected encoding scheme.isBigEndian-Detected byte order of the data.
trueif order is big-endian,falseif little-endian, andnullif byte order is not relevant for this encoding scheme.
-
EncodingInfo
public EncodingInfo(String encoding, Boolean isBigEndian, boolean hasBOM)
Constructor that takes name of the encoding scheme and endianness - results of autodetection ingetEncodingName(). Also presence of Byte Order Mark should be specified explicitly.- Parameters:
encoding- Name of the autodetected encoding scheme.isBigEndian-Detected byte order of the data.
trueif order is big-endian,falseif little-endian, andnullif byte order is not relevant for this encoding scheme.hasBOM-trueif BOM is present,falseotherwise.
-
-
Method Detail
-
getEncoding
public String getEncoding()
Returns current encoding scheme (or charset).
-
setEncoding
public void setEncoding(String encoding)
Sets new value of stored encoding (charset?) name.
-
isBigEndian
public Boolean isBigEndian()
Accessor forfIsBigEndian. Should we define a mutator too?
-
hasBOM
public boolean hasBOM()
Accessor forfHasBOM. Imho mutator is not required.
-
copyFrom
public void copyFrom(EncodingInfo encInfo)
Copies property values from anotherEncodingInfoinstance. Strange enough, but sometimes such behavior is preferred to simple assignment or cloning. More specifically, this method is currently used (at least it was :) inXmlCharsetDetector.getCharsetAwareReader(other two ways simply don't work).- Parameters:
encInfo- source object which properties should be mirrored in this instance
-
-