summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java')
-rw-r--r--pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java94
1 files changed, 48 insertions, 46 deletions
diff --git a/pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java b/pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java
index 9defa7646..972c57846 100644
--- a/pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java
+++ b/pki/base/util/src/netscape/security/util/ASN1CharStrConvMap.java
@@ -29,60 +29,60 @@ import java.util.Map;
* Maps a ASN.1 character string type to a charset encoder and decoder.
* The converter is used to convert a DerValue of a ASN.1 character string type
* from bytes to unicode characters and vice versa.
- *
- * <p>A global default ASN1CharStrConvMap is created when the class is
- * initialized. The global default map is extensible.
- *
+ *
+ * <p>
+ * A global default ASN1CharStrConvMap is created when the class is initialized. The global default map is extensible.
+ *
* @author Lily Hsiao
* @author Slava Galperin
- *
+ *
*/
-public class ASN1CharStrConvMap
-{
+public class ASN1CharStrConvMap {
// public constructors
/**
* Constructs a ASN1CharStrConvMap.
*/
- public ASN1CharStrConvMap()
- {
+ public ASN1CharStrConvMap() {
}
/**
* Get an encoder for the specified DER tag.
- *
- * @param tag A DER tag of a ASN.1 character string type,
- * for example DerValue.tag_PrintableString.
- *
- * @return An encoder for the DER tag.
+ *
+ * @param tag A DER tag of a ASN.1 character string type,
+ * for example DerValue.tag_PrintableString.
+ *
+ * @return An encoder for the DER tag.
*/
public CharsetEncoder getEncoder(byte tag) {
Charset charset = charsets.get(tag);
- if (charset == null) return null;
+ if (charset == null)
+ return null;
return charset.newEncoder();
}
/**
* Get a decoder for the given DER tag.
- *
- * @param tag A DER tag of a ASN.1 character string type,
- * for example DerValue.tag_PrintableString.
- *
- * @return A decoder for the DER tag.
+ *
+ * @param tag A DER tag of a ASN.1 character string type,
+ * for example DerValue.tag_PrintableString.
+ *
+ * @return A decoder for the DER tag.
*/
public CharsetDecoder getDecoder(byte tag) {
Charset charset = charsets.get(tag);
- if (charset == null) return null;
+ if (charset == null)
+ return null;
return charset.newDecoder();
}
/**
* Add a tag-charset entry in the map.
- *
- * @param tag A DER tag of a ASN.1 character string type,
- * ex. DerValue.tag_IA5String
- * @param charset A charset for the tag.
+ *
+ * @param tag A DER tag of a ASN.1 character string type,
+ * ex. DerValue.tag_IA5String
+ * @param charset A charset for the tag.
*/
public void addEntry(byte tag, Charset charset) {
@@ -91,7 +91,7 @@ public class ASN1CharStrConvMap
if (currentCharset != null) {
if (currentCharset != charset) {
throw new IllegalArgumentException(
- "a DER tag to converter entry already exists.");
+ "a DER tag to converter entry already exists.");
} else {
return;
}
@@ -99,9 +99,11 @@ public class ASN1CharStrConvMap
charsets.put(tag, charset);
}
+
/**
* Get an iterator of all tags in the map.
- * @return An Iterator of DER tags in the map as Bytes.
+ *
+ * @return An Iterator of DER tags in the map as Bytes.
*/
public Iterator<Byte> getTags() {
return charsets.keySet().iterator();
@@ -111,23 +113,23 @@ public class ASN1CharStrConvMap
/**
* Get the global ASN1CharStrConvMap.
- * @return The global default ASN1CharStrConvMap.
+ *
+ * @return The global default ASN1CharStrConvMap.
*/
- static public ASN1CharStrConvMap getDefault()
- {
- return defaultMap;
+ static public ASN1CharStrConvMap getDefault() {
+ return defaultMap;
}
/**
* Set the global default ASN1CharStrConvMap.
- * @param newDefault The new default ASN1CharStrConvMap.
+ *
+ * @param newDefault The new default ASN1CharStrConvMap.
*/
- static public void setDefault(ASN1CharStrConvMap newDefault)
- {
- if (newDefault == null)
- throw new IllegalArgumentException(
- "Cannot set a null default Der Tag Converter map");
- defaultMap = newDefault;
+ static public void setDefault(ASN1CharStrConvMap newDefault) {
+ if (newDefault == null)
+ throw new IllegalArgumentException(
+ "Cannot set a null default Der Tag Converter map");
+ defaultMap = newDefault;
}
// private methods and variables.
@@ -144,24 +146,24 @@ public class ASN1CharStrConvMap
defaultMap = new ASN1CharStrConvMap();
defaultMap.addEntry(DerValue.tag_PrintableString,
- provider.charsetForName("ASN.1-Printable"));
+ provider.charsetForName("ASN.1-Printable"));
defaultMap.addEntry(DerValue.tag_VisibleString,
- provider.charsetForName("ASN.1-Printable"));
+ provider.charsetForName("ASN.1-Printable"));
defaultMap.addEntry(DerValue.tag_IA5String,
- provider.charsetForName("ASN.1-IA5"));
+ provider.charsetForName("ASN.1-IA5"));
defaultMap.addEntry(DerValue.tag_BMPString,
- Charset.forName("UnicodeBig"));
+ Charset.forName("UnicodeBig"));
defaultMap.addEntry(DerValue.tag_UniversalString,
- provider.charsetForName("ASN.1-Universal"));
+ provider.charsetForName("ASN.1-Universal"));
// XXX this is an oversimplified implementation of T.61 strings, it
// doesn't handle all cases
defaultMap.addEntry(DerValue.tag_T61String,
- Charset.forName("ISO-8859-1"));
+ Charset.forName("ISO-8859-1"));
// UTF8String added to ASN.1 in 1998
defaultMap.addEntry(DerValue.tag_UTF8String,
- Charset.forName("UTF-8"));
+ Charset.forName("UTF-8"));
defaultMap.addEntry(DerValue.tag_GeneralString,
- Charset.forName("UTF-8"));
+ Charset.forName("UTF-8"));
};
};