[DMAAP-48] Initial code import
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / json / HTTPTokener.java
diff --git a/datarouter-prov/src/main/java/org/json/HTTPTokener.java b/datarouter-prov/src/main/java/org/json/HTTPTokener.java
new file mode 100644 (file)
index 0000000..0594e74
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************\r
+ * ============LICENSE_START==================================================\r
+ * * org.onap.dmaap\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.json;\r
+\r
+/*\r
+Copyright (c) 2002 JSON.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in all\r
+copies or substantial portions of the Software.\r
+\r
+The Software shall be used for Good, not Evil.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+SOFTWARE.\r
+*/\r
+\r
+/**\r
+ * The HTTPTokener extends the JSONTokener to provide additional methods\r
+ * for the parsing of HTTP headers.\r
+ * @author JSON.org\r
+ * @version 2012-11-13\r
+ */\r
+public class HTTPTokener extends JSONTokener {\r
+\r
+    /**\r
+     * Construct an HTTPTokener from a string.\r
+     * @param string A source string.\r
+     */\r
+    public HTTPTokener(String string) {\r
+        super(string);\r
+    }\r
+\r
+\r
+    /**\r
+     * Get the next token or string. This is used in parsing HTTP headers.\r
+     * @throws JSONException\r
+     * @return A String.\r
+     */\r
+    public String nextToken() throws JSONException {\r
+        char c;\r
+        char q;\r
+        StringBuffer sb = new StringBuffer();\r
+        do {\r
+            c = next();\r
+        } while (Character.isWhitespace(c));\r
+        if (c == '"' || c == '\'') {\r
+            q = c;\r
+            for (;;) {\r
+                c = next();\r
+                if (c < ' ') {\r
+                    throw syntaxError("Unterminated string.");\r
+                }\r
+                if (c == q) {\r
+                    return sb.toString();\r
+                }\r
+                sb.append(c);\r
+            }\r
+        }\r
+        for (;;) {\r
+            if (c == 0 || Character.isWhitespace(c)) {\r
+                return sb.toString();\r
+            }\r
+            sb.append(c);\r
+            c = next();\r
+        }\r
+    }\r
+}\r