+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 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\r
-//\r
-// SilkFunction.java\r
-// Since: Jan 30, 2009 7:36:19 PM\r
-//\r
-// $URL: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core/src/main/java/org/xerial/silk/impl/SilkFunction.java $\r
-// $Author: leo $\r
-//--------------------------------------\r
-package org.xerial.silk.impl;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.xerial.core.XerialError;\r
-import org.xerial.core.XerialErrorCode;\r
-import org.xerial.util.StringUtil;\r
-\r
-/**\r
- * function data\r
- * \r
- * @author leo\r
- * \r
- */\r
-public class SilkFunction implements SilkElement, SilkValue\r
-{\r
- private String name;\r
- private String indent;\r
- private ArrayList<SilkFunctionArg> argumentList = new ArrayList<SilkFunctionArg>();\r
-\r
- public final static int NO_INDENT = Integer.MAX_VALUE; // must be higher than other indent levels\r
-\r
- /**\r
- * Return the indent level (the length of the leadning white spaces) of this\r
- * node. If no indent is specified, return {@link SilkNode#NO_INDENT}.\r
- * \r
- * @return the indent level of the node, or {@link SilkNode#NO_INDENT} if no\r
- * indent is specified.\r
- */\r
- public int getIndentLevel()\r
- {\r
- if (indent == null)\r
- return NO_INDENT;\r
- else\r
- return indent.length() - 1;\r
- }\r
-\r
- public void setName(String name)\r
- {\r
- this.name = name;\r
- }\r
-\r
- public String getName()\r
- {\r
- return name;\r
- }\r
-\r
- public void addArgument(String argument)\r
- {\r
- argumentList.add(SilkFunctionArg.newArgValue(argument));\r
- }\r
-\r
- public void addKeyValuePair(SilkFunctionArg argument)\r
- {\r
- argumentList.add(argument);\r
- }\r
-\r
- public void addKeyAndValue(String key, String value)\r
- {\r
- argumentList.add(new SilkFunctionArg(key, value));\r
- }\r
-\r
- public List<SilkFunctionArg> getArgumentList()\r
- {\r
- return argumentList;\r
- }\r
-\r
- public String getNodeIndent()\r
- {\r
- return indent;\r
- }\r
-\r
- public void setNodeIndent(String indent)\r
- {\r
- this.indent = indent;\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- return String.format("function %s(%s)", name, StringUtil.join(argumentList, ", "));\r
- }\r
-\r
- public String getValue()\r
- {\r
- throw new XerialError(XerialErrorCode.UNSUPPORTED, "getValue() for SilkFunction");\r
- }\r
-\r
- public boolean isJSON()\r
- {\r
- return false;\r
- }\r
-\r
- public boolean isFunction()\r
- {\r
- return true;\r
- }\r
-\r
-}\r