List of usage examples for java.util Stack clone
@HotSpotIntrinsicCandidate protected native Object clone() throws CloneNotSupportedException;
From source file:org.jolokia.handler.list.MBeanInfoData.java
/** * Constructor taking a max depth. The <em>max depth</em> specifies how deep the info tree should be build * up. The tree will be truncated if it gets larger than this value. A <em>path</em> (in form of a stack) * can be given, in which only a sub information is (sub-tree or leaf value) is stored * * @param pMaxDepth max depth//from w w w . j a v a 2 s . com * @param pPathStack the stack for restricting the information to add. The given stack will be cloned * and is left untouched. * @param pUseCanonicalName whether to use canonical name in listings */ public MBeanInfoData(int pMaxDepth, Stack<String> pPathStack, boolean pUseCanonicalName) { maxDepth = pMaxDepth; useCanonicalName = pUseCanonicalName; pathStack = pPathStack != null ? (Stack<String>) pPathStack.clone() : new Stack<String>(); infoMap = new JSONObject(); }
From source file:tk.tomby.tedit.syntax.Tokenizer.java
/** * DOCUMENT ME!//from ww w .ja v a 2 s .c o m * * @param text DOCUMENT ME! * @param state DOCUMENT ME! */ public void reinit(String text, Stack state) { this.text = text; this.state = (Stack) state.clone(); initMatcher(); }
From source file:org.jolokia.converter.json.TabularDataExtractor.java
private Object convertMxBeanMapToJson(TabularData pTd, Stack<String> pExtraArgs, ObjectToJsonConverter pConverter) throws AttributeNotFoundException { JSONObject ret = new JSONObject(); for (Object rowObject : pTd.values()) { CompositeData row = (CompositeData) rowObject; Stack<String> path = (Stack<String>) pExtraArgs.clone(); Object keyObject = row.get("key"); if (keyObject != null) { try { Object value = pConverter.extractObject(row.get("value"), path, true); ret.put(keyObject.toString(), value); } catch (ValueFaultHandler.AttributeFilteredException exp) { // Skip to next object since attribute was filtered }/*from w ww. jav a2 s . c o m*/ } } if (!pTd.isEmpty() && ret.isEmpty()) { // Bubble up if not a single thingy has been found throw new ValueFaultHandler.AttributeFilteredException(); } return ret; }
From source file:org.jolokia.converter.json.TabularDataExtractor.java
private Object convertToMaps(TabularData pTd, Stack<String> pExtraArgs, ObjectToJsonConverter pConverter) throws AttributeNotFoundException { JSONObject ret = new JSONObject(); TabularType type = pTd.getTabularType(); List<String> indexNames = type.getIndexNames(); boolean found = false; for (CompositeData cd : (Collection<CompositeData>) pTd.values()) { Stack<String> path = (Stack<String>) pExtraArgs.clone(); try {/* ww w . java 2s . co m*/ JSONObject targetJSONObject = ret; // TODO: Check whether all keys can be represented as simple types. If not, well // we dont do any magic and return the tabular data as an array. for (int i = 0; i < indexNames.size() - 1; i++) { Object indexValue = pConverter.extractObject(cd.get(indexNames.get(i)), null, true); targetJSONObject = getNextMap(targetJSONObject, indexValue); } Object row = pConverter.extractObject(cd, path, true); String finalIndex = indexNames.get(indexNames.size() - 1); Object finalIndexValue = pConverter.extractObject(cd.get(finalIndex), null, true); targetJSONObject.put(finalIndexValue, row); found = true; } catch (ValueFaultHandler.AttributeFilteredException exp) { // Ignoring filtered attributes } } if (!pTd.isEmpty() && !found) { throw new ValueFaultHandler.AttributeFilteredException(); } return ret; }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.generator.DifferentLevelArrayMappingConfigGenerator.java
@SuppressWarnings("unchecked") private String getJSCommandForOperation(MappingOperation mappingOperation, Map<String, SchemaDataType> variableTypeMap, ForLoopBean forLoopBean) { StringBuilder operationBuilder = new StringBuilder(); List<DMVariable> outputVariables = mappingOperation.getOutputVariables(); if (outputVariables.size() > 1) { operationBuilder.append("[ "); }// w w w . j a v a 2 s . c o m Stack<ForLoopBean> forLoopBeanParentStack = getParentForLoopBeanStack(forLoopBean); Stack<ForLoopBean> tempForLoopBeanParentStack = new Stack<ForLoopBean>(); tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); int numOfOutputVariables = outputVariables.size(); for (int variableIndex = 0; variableIndex < numOfOutputVariables; variableIndex++) { operationBuilder.append(ScriptGenerationUtil.getPrettyVariableNameInForOperation( outputVariables.get(variableIndex), variableTypeMap, tempForLoopBeanParentStack)); if (variableIndex < (numOfOutputVariables - 1)) { operationBuilder.append(","); } else if (numOfOutputVariables > 1) { operationBuilder.append(" ] "); } } operationBuilder.append(" = "); DMOperatorTransformer operatorTransformer = DMOperatorTransformerFactory .getDMOperatorTransformer(mappingOperation.getOperation().getOperatorType()); operationBuilder.append( operatorTransformer.generateScriptForOperation(DifferentLevelArrayMappingConfigGenerator.class, mappingOperation.getInputVariables(), variableTypeMap, forLoopBeanParentStack)); operationBuilder.append("\n"); return operationBuilder.toString(); }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.generator.DifferentLevelArrayMappingConfigGenerator.java
@SuppressWarnings("unchecked") private List<String> getArrayTypeVariablesList(ForLoopBean forLoopBean, List<MappingOperation> mappingOperationList, Map<String, SchemaDataType> variableTypeMap) { List<String> initializedVariableList = new ArrayList<>(); Stack<ForLoopBean> forLoopBeanParentStack = getParentForLoopBeanStack(forLoopBean); Stack<ForLoopBean> tempForLoopBeanParentStack = new Stack<ForLoopBean>(); tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); for (int operationIndex : forLoopBean.getOperationList()) { MappingOperation mappingOperation = mappingOperationList.get(operationIndex); for (DMVariable outputVariable : mappingOperation.getOutputVariables()) { tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); if (DMVariableType.OUTPUT.equals(outputVariable.getType())) { String outputVariableName = outputVariable.getName(); String[] outputVariableArray = outputVariableName.split("\\."); String fieldName = outputVariableArray[outputVariableArray.length - 1]; String variableName = removeLastElementNameFromVariable(outputVariableName); if (variableTypeMap.containsKey(variableName)) { if (fieldName.contains(SCHEMA_ATTRIBUTE_PREFIX) && ScriptGenerationUtil .isVariableTypePrimitive(variableTypeMap.get(variableName))) { String variableString = ScriptGenerationUtil.getPrettyVariableNameInForOperation( outputVariable, variableTypeMap, tempForLoopBeanParentStack); variableString = removeLastElementNameFromVariable(variableString); if (!initializedVariableList.contains(variableString)) { initializedVariableList.add(variableString); }/*from w w w .j a v a2 s. c om*/ } } else { throw new IllegalArgumentException( "Illegal variable name found" + outputVariable.getName()); } } } } return initializedVariableList; }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.generator.DifferentLevelArrayMappingConfigGenerator.java
@SuppressWarnings("unchecked") private String transformForLoopBeansToJS(ForLoopBean forLoopBean, List<MappingOperation> mappingOperationList, Map<String, SchemaDataType> variableTypeMap) { StringBuilder functionBuilder = new StringBuilder(); functionBuilder.append("\n"); Stack<ForLoopBean> forLoopBeanParentStack = getParentForLoopBeanStack(forLoopBean); Stack<ForLoopBean> tempForLoopBeanParentStack = new Stack<ForLoopBean>(); tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); List<String> arrayTypeVariableList = getArrayTypeVariablesList(forLoopBean, mappingOperationList, variableTypeMap);//from w w w .j a v a 2 s. c o m // Initiating objects of Array type variables" functionBuilder .append(initiateArrayTypeVariables(forLoopBean, tempForLoopBeanParentStack, variableTypeMap)); functionBuilder.append("\n"); if (!ROOT_TAG.equals(forLoopBean.getVariableName())) { String forLoopVariableName = ScriptGenerationUtil.getPrettyVariableNameInForOperation( new DMVariable(forLoopBean.getVariableName(), "", DMVariableType.INPUT, SchemaDataType.ARRAY, -1), variableTypeMap, tempForLoopBeanParentStack); functionBuilder.append("for(" + forLoopBean.getIterativeName() + " in " + forLoopVariableName.substring(0, forLoopVariableName.lastIndexOf("[")) + "){"); functionBuilder.append("\n"); } tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); // Initiating arrays of the output variable going to instantiate in below for loop functionBuilder.append( initiateArrayTypeVariablesObjects(forLoopBean, tempForLoopBeanParentStack, variableTypeMap)); functionBuilder.append("\n"); tempForLoopBeanParentStack = (Stack<ForLoopBean>) forLoopBeanParentStack.clone(); // Initiating objects of the output variable functionBuilder .append(initiateRecordTypeVariables(forLoopBean, tempForLoopBeanParentStack, variableTypeMap)); functionBuilder.append("\n"); // Initiating Attribute objects of the output variable functionBuilder.append(getJSInitializationForArrayVariableObjects(arrayTypeVariableList)); // call operations and nested for loops List<Integer> operationsInForLoopList = forLoopBean.getOperationList(); for (Integer operationIndex : operationsInForLoopList) { functionBuilder.append(getJSCommandForOperation(mappingOperationList.get(operationIndex), variableTypeMap, forLoopBean)); } List<Integer> nestedForLoopList = forLoopBean.getNestedForLoopList(); for (Integer nestedForLoopIndex : nestedForLoopList) { functionBuilder.append(transformForLoopBeansToJS(getForLoopBeanList().get(nestedForLoopIndex), mappingOperationList, variableTypeMap)); } if (!ROOT_TAG.equals(forLoopBean.getVariableName())) { functionBuilder.append("\n"); functionBuilder.append("}"); functionBuilder.append("\n"); } return functionBuilder.toString(); }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.configuration.operator.transformers.MatchOperatorTransformer.java
@Override public String generateScriptForOperation(Class<?> generatorClass, List<DMVariable> inputVariables, List<DMVariable> outputVariables, Map<String, List<SchemaDataType>> variableTypeMap, Stack<ForLoopBean> parentForLoopBeanStack, DMOperation operator, List<ForLoopBean> forLoopBeanList, Map<String, Integer> outputArrayVariableForLoop, Map<String, Integer> outputArrayRootVariableForLoop) throws DataMapperException { StringBuilder operationBuilder = new StringBuilder(); operationBuilder//w ww . ja v a 2s .c om .append(appendOutputVariable(operator, outputVariables, variableTypeMap, parentForLoopBeanStack, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); if (DifferentLevelArrayMappingConfigGenerator.class.equals(generatorClass)) { if (inputVariables.get(0) == null) { throw new IllegalArgumentException("Match operator needs input string value to execute"); } String customInput = (String) operator.getProperty(TransformerConstants.PATTERN_TAG); @SuppressWarnings("unchecked") Stack<ForLoopBean> tempParentForLoopBeanStack = (Stack<ForLoopBean>) parentForLoopBeanStack.clone(); if (inputVariables.size() > 0) { operationBuilder.append("(" + ScriptGenerationUtil.getPrettyVariableNameInForOperation(inputVariables.get(0), variableTypeMap, parentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop) + ")" + JS_TO_STRING + ".match("); } if (customInput != null) { if (inputVariables.size() == 2 && customInput.startsWith("{$")) { operationBuilder.append(ScriptGenerationUtil.getPrettyVariableNameInForOperation( inputVariables.get(1), variableTypeMap, tempParentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); } else { if (customInput.startsWith("{$") || StringUtils.isEmpty(customInput)) { throw new IllegalArgumentException("Match operator needs pattern to execute." + " Link element to pattern connector or configure pattern string"); } operationBuilder.append(customInput); } } operationBuilder.append(")!= null ? true : false;"); } else { throw new IllegalArgumentException("Unknown MappingConfigGenerator type found : " + generatorClass); } return operationBuilder.toString(); }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.configuration.operator.transformers.EndsWithOperatorTransformer.java
@Override public String generateScriptForOperation(Class<?> generatorClass, List<DMVariable> inputVariables, List<DMVariable> outputVariables, Map<String, List<SchemaDataType>> variableTypeMap, Stack<ForLoopBean> parentForLoopBeanStack, DMOperation operator, List<ForLoopBean> forLoopBeanList, Map<String, Integer> outputArrayVariableForLoop, Map<String, Integer> outputArrayRootVariableForLoop) throws DataMapperException { StringBuilder operationBuilder = new StringBuilder(); operationBuilder/*w ww. j a v a 2 s .co m*/ .append(appendOutputVariable(operator, outputVariables, variableTypeMap, parentForLoopBeanStack, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); if (DifferentLevelArrayMappingConfigGenerator.class.equals(generatorClass)) { if (inputVariables.get(0) == null) { throw new IllegalArgumentException("EndsWith operator needs input string value to execute"); } String inputMethod = (String) operator.getProperty(TransformerConstants.PATTERN_TAG); @SuppressWarnings("unchecked") Stack<ForLoopBean> tempParentForLoopBeanStack = (Stack<ForLoopBean>) parentForLoopBeanStack.clone(); if (inputVariables.size() > 0) { operationBuilder.append("(" + ScriptGenerationUtil.getPrettyVariableNameInForOperation( inputVariables.get(0), variableTypeMap, parentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop) + ")"); } if (inputMethod != null) { if (inputVariables.size() == 2 && inputMethod.startsWith("{$")) { operationBuilder.append(JS_TO_STRING + ".endsWith(" + ScriptGenerationUtil.getPrettyVariableNameInForOperation(inputVariables.get(1), variableTypeMap, tempParentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop) + ")"); } else { if (inputMethod.startsWith("{$") || StringUtils .isEmpty((String) operator.getProperty(TransformerConstants.PATTERN_TAG))) { throw new IllegalArgumentException("EndsWith operator needs pattern to execute." + " Link element to pattern connector or configure pattern string"); } operationBuilder.append(JS_TO_STRING + ".endsWith(\"" + operator.getProperty(TransformerConstants.PATTERN_TAG) + "\")"); } } else { operationBuilder.append(JS_TO_STRING + ".endsWith(\"\")"); } operationBuilder.append(";"); } else { throw new IllegalArgumentException("Unknown MappingConfigGenerator type found : " + generatorClass); } return operationBuilder.toString(); }
From source file:org.wso2.developerstudio.datamapper.diagram.custom.configuration.operator.transformers.StartsWithOperatorTransformer.java
@Override public String generateScriptForOperation(Class<?> generatorClass, List<DMVariable> inputVariables, List<DMVariable> outputVariables, Map<String, List<SchemaDataType>> variableTypeMap, Stack<ForLoopBean> parentForLoopBeanStack, DMOperation operator, List<ForLoopBean> forLoopBeanList, Map<String, Integer> outputArrayVariableForLoop, Map<String, Integer> outputArrayRootVariableForLoop) throws DataMapperException { StringBuilder operationBuilder = new StringBuilder(); operationBuilder/*from w w w. j ava 2s . c o m*/ .append(appendOutputVariable(operator, outputVariables, variableTypeMap, parentForLoopBeanStack, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); if (DifferentLevelArrayMappingConfigGenerator.class.equals(generatorClass)) { if (inputVariables.get(0) == null) { throw new IllegalArgumentException("StartsWith operator needs input string value to execute"); } String inputMethod = (String) operator.getProperty(TransformerConstants.PATTERN_TAG); @SuppressWarnings("unchecked") Stack<ForLoopBean> tempParentForLoopBeanStack = (Stack<ForLoopBean>) parentForLoopBeanStack.clone(); if (inputVariables.size() > 0) { operationBuilder.append("(" + ScriptGenerationUtil.getPrettyVariableNameInForOperation( inputVariables.get(0), variableTypeMap, parentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop) + ")"); } if (inputMethod != null) { if (inputVariables.size() == 2 && inputMethod.startsWith("{$")) { operationBuilder.append(JS_TO_STRING + ".startsWith(" + ScriptGenerationUtil.getPrettyVariableNameInForOperation(inputVariables.get(1), variableTypeMap, tempParentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop) + ")"); } else { if (inputMethod.startsWith("{$") || StringUtils .isEmpty((String) operator.getProperty(TransformerConstants.PATTERN_TAG))) { throw new IllegalArgumentException("StartsWith operator needs pattern to execute." + " Link element to pattern connector or configure pattern string"); } operationBuilder.append(JS_TO_STRING + ".startsWith(\"" + operator.getProperty(TransformerConstants.PATTERN_TAG) + "\")"); } } else { operationBuilder.append(JS_TO_STRING + ".startsWith(\"\")"); } operationBuilder.append(";"); } else { throw new IllegalArgumentException("Unknown MappingConfigGenerator type found : " + generatorClass); } return operationBuilder.toString(); }