Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/spongycastle/asn1/OIDTokenizer.java')
-rw-r--r--core/src/main/java/org/spongycastle/asn1/OIDTokenizer.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/core/src/main/java/org/spongycastle/asn1/OIDTokenizer.java b/core/src/main/java/org/spongycastle/asn1/OIDTokenizer.java
new file mode 100644
index 00000000..e618f4b9
--- /dev/null
+++ b/core/src/main/java/org/spongycastle/asn1/OIDTokenizer.java
@@ -0,0 +1,48 @@
+package org.spongycastle.asn1;
+
+/**
+ * class for breaking up an OID into it's component tokens, ala
+ * java.util.StringTokenizer. We need this class as some of the
+ * lightweight Java environment don't support classes like
+ * StringTokenizer.
+ */
+public class OIDTokenizer
+{
+ private String oid;
+ private int index;
+
+ public OIDTokenizer(
+ String oid)
+ {
+ this.oid = oid;
+ this.index = 0;
+ }
+
+ public boolean hasMoreTokens()
+ {
+ return (index != -1);
+ }
+
+ public String nextToken()
+ {
+ if (index == -1)
+ {
+ return null;
+ }
+
+ String token;
+ int end = oid.indexOf('.', index);
+
+ if (end == -1)
+ {
+ token = oid.substring(index);
+ index = -1;
+ return token;
+ }
+
+ token = oid.substring(index, end);
+
+ index = end + 1;
+ return token;
+ }
+}