|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.nand.util.i18n.PropsFileParser
public class PropsFileParser
Represents a parsed properties file.
Usage:
parseOneFile(File)
to read and parse the file.
PropsFileWriter
.
ParsedPropsFilePair
to work with two related property files with similar sets of keys.
Remember that .properties
bundle files are encoded not in UTF-8
but in ISO-8859-1
:
\uXXXX
code escapes.
PropsFileWriter
Nested Class Summary | |
---|---|
static class |
PropsFileParser.KeyPairLine
Parsed key-pair line from one properties file; includes its preceding PropsFileParser.KeyPairLine.comment lines, if any. |
Field Summary | |
---|---|
static java.lang.String |
KEY_PREFIX_NO_LOCALIZE
If a key starts with this prefix "_nolocaliz" , it should be present only in the
source language (something.properties), and never localized (something_lang.properties). |
Constructor Summary | |
---|---|
PropsFileParser()
|
Method Summary | |
---|---|
static void |
findDuplicateKeys(java.util.List<PropsFileParser.KeyPairLine> kpLines,
java.util.Map<java.lang.String,java.lang.String> dupeKeys)
Search a list of key-pair lines for any duplicates, filling the dupeKeys map. |
static java.util.List<PropsFileParser.KeyPairLine> |
parseOneFile(java.io.File pFile)
Parse one properties file. |
static java.util.List<PropsFileParser.KeyPairLine> |
parseOneFile(java.io.File pFile,
java.util.Map<java.lang.String,java.lang.String> dupeKeys)
Parse one properties file. |
private static java.lang.String |
unescapeUnicodes(java.lang.String valStr)
Un-escape \uXXXX sequences into unicode characters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String KEY_PREFIX_NO_LOCALIZE
"_nolocaliz"
, it should be present only in the
source language (something.properties), and never localized (something_lang.properties).
Constructor Detail |
---|
public PropsFileParser()
Method Detail |
---|
public static java.util.List<PropsFileParser.KeyPairLine> parseOneFile(java.io.File pFile) throws java.io.IOException, java.lang.SecurityException, java.io.UnsupportedEncodingException
pFile
- File to parse
java.io.IOException
- If file not found, cannot be read, etc.
java.lang.SecurityException
- if read access is denied
java.io.UnsupportedEncodingException
- if the "ISO-8859-1"
file encoding is somehow not supported;
this is the encoding used by Java properties files, so it should be available;
this error is not expected to occur.public static java.util.List<PropsFileParser.KeyPairLine> parseOneFile(java.io.File pFile, java.util.Map<java.lang.String,java.lang.String> dupeKeys) throws java.io.IOException, java.lang.SecurityException, java.io.UnsupportedEncodingException
pFile
- File to parsedupeKeys
- Output param for noting any duplicate key names and their values, or null
.
Key = each key seen more than once while parsing, value = values for that key.
For structure details see findDuplicateKeys(List, Map)
,
including special case of 'duplicates' with same value.
java.io.IOException
- If file not found, cannot be read, etc.
java.lang.SecurityException
- if read access is denied
java.io.UnsupportedEncodingException
- if the "ISO-8859-1"
file encoding is somehow not supported;
this is the encoding used by Java properties files, so it should be available;
this error is not expected to occur.public static void findDuplicateKeys(java.util.List<PropsFileParser.KeyPairLine> kpLines, java.util.Map<java.lang.String,java.lang.String> dupeKeys)
dupeKeys
map.
kpLines
- Key-pair lines to search for duplicates, as returned by parseOneFile(File)
.dupeKeys
- Output param for noting any duplicate key names and their values.
This should be empty when called.
Special case: If a key appears more than once with exactly the same value, it won't be considered a dupe and won't be placed in this map.
private static java.lang.String unescapeUnicodes(java.lang.String valStr)
\uXXXX
sequences into unicode characters.
valStr
- String containing unicode escape sequences
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |