+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2007 Taro L. Saito\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
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ Project\r
-//\r
-// JSONValueBase.java\r
-// Since: Apr 4, 2007\r
-//\r
-// $URL: http://dev.utgenome.org/svn/utgb/trunk/common/src/org/utgenome/json/JSONValueBase.java $ \r
-// $Author: leo $\r
-//--------------------------------------\r
-package org.xerial.json;\r
-\r
-import java.util.Collection;\r
-import java.util.Iterator;\r
-\r
-/**\r
- * Base implementation of the JSONValue\r
- * \r
- * @author leo\r
- * \r
- */\r
-public abstract class JSONValueBase implements JSONValue {\r
-\r
- public JSONArray getJSONArray() {\r
- return null;\r
- }\r
-\r
- public JSONBoolean getJSONBoolean() {\r
- return null;\r
- }\r
-\r
- public JSONNull getJSONNull() {\r
- return null;\r
- }\r
-\r
- public JSONNumber getJSONNumber() {\r
- return null;\r
- }\r
-\r
- public JSONObject getJSONObject() {\r
- return null;\r
- }\r
-\r
- public JSONString getJSONString() {\r
- return null;\r
- }\r
-\r
- public JSONValue translateAsJSONValue(Object value) throws JSONException {\r
- return JSONUtil.toJSONValue(value);\r
- }\r
-\r
- public String toJSONString() {\r
- return this.toString();\r
- }\r
-\r
- /**\r
- * Concatenates all elements in the given collection c into a single string\r
- * with the separator\r
- * \r
- * @param c\r
- * collection of elements to concatenate\r
- * @param concatinator\r
- * string for concatenating elements: e.g., ", ", "." etc.\r
- * @return a concatenated string\r
- */\r
- protected static String join(Collection< ? > c, String concatinator) {\r
- if (c == null)\r
- return "";\r
- int size = c.size();\r
- if (size == 0)\r
- return "";\r
-\r
- Iterator< ? > it = c.iterator();\r
- StringBuilder buf = new StringBuilder();\r
- for (int i = 0; it.hasNext() && i < size - 1; i++) {\r
- Object data = it.next();\r
- buf.append(data.toString());\r
- buf.append(concatinator);\r
- }\r
- Object lastData = it.next();\r
- buf.append(lastData.toString());\r
- return buf.toString();\r
- }\r
-}\r