/** * Get a copy of this path * * @return A copy of this path. */ @SuppressWarnings("unchecked") public Path getACopy() { Path newPath = new Path(); newPath.root = this.root; newPath.edgePath = (Stack<Edge>) edgePath.clone(); newPath.nodePath = (Stack<Node>) nodePath.clone(); return newPath; }
/** * @param progressMonitor * @param uriMappings * @param resource * @param methodsStack * @throws CoreException */ private void resolveResourcesUriMappings( final Resource resource, final String uriTemplateFragment, final Map<ResolvedUriMapping, Stack<ResourceMethod>> uriMappings, final Stack<ResourceMethod> methodsStack, final IProgressMonitor progressMonitor) throws CoreException { // resource resourceMethods and subresources resourceMethods are treated the same way for (ResourceMethod resourceMethod : resource.getAllMethods()) { String uriPathTemplate = resolveURIPathTemplate(uriTemplateFragment, resource, resourceMethod); MediaTypeCapabilities mediaTypeCapabilities = resolveMediaTypeCapabilities(resource, resourceMethod); UriMapping resourceUriMapping = resourceMethod.getUriMapping(); ResolvedUriMapping uriMapping = new ResolvedUriMapping( resourceUriMapping.getHTTPMethod(), uriPathTemplate, resourceUriMapping.getQueryParams(), mediaTypeCapabilities); @SuppressWarnings("unchecked") Stack<ResourceMethod> stack = (Stack<ResourceMethod>) methodsStack.clone(); stack.add(resourceMethod); uriMappings.put(uriMapping, stack); } // TODO : verify support chain of subresource locators // TODO : stack resourceMethods and detect+prevent cycles for (ResourceMethod resourceMethod : resource.getSubresourceLocators()) { String uriPathTemplate = resolveURIPathTemplate(uriTemplateFragment, resource, resourceMethod); IType returnType = resourceMethod.getReturnType(); if (returnType == null) { continue; } ITypeHierarchy subresourceTypeHierarchy = JdtUtils.resolveTypeHierarchy(returnType, false, progressMonitor); for (IType subresourceType : subresourceTypeHierarchy.getSubtypes(returnType)) { Resource subresource = getByType(subresourceType); if (subresource != null && !subresource.isRootResource()) { @SuppressWarnings("unchecked") Stack<ResourceMethod> stack = (Stack<ResourceMethod>) methodsStack.clone(); stack.add(resourceMethod); resolveResourcesUriMappings( subresource, uriPathTemplate, uriMappings, stack, progressMonitor); } } } }
@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.append( appendOutputVariable( operator, outputVariables, variableTypeMap, parentForLoopBeanStack, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); if (DifferentLevelArrayMappingConfigGenerator.class.equals(generatorClass)) { @SuppressWarnings("unchecked") Stack<ForLoopBean> tempParentForLoopBeanStack = (Stack<ForLoopBean>) parentForLoopBeanStack.clone(); /* Add Initializer */ operationBuilder.append("Math.max("); if (inputVariables.size() > 0) { operationBuilder.append( ScriptGenerationUtil.getPrettyVariableNameInForOperation( inputVariables.get(0), variableTypeMap, parentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); for (int variableIndex = 1; variableIndex < inputVariables.size(); variableIndex++) { operationBuilder.append( "," + ScriptGenerationUtil.getPrettyVariableNameInForOperation( inputVariables.get(variableIndex), variableTypeMap, tempParentForLoopBeanStack, true, forLoopBeanList, outputArrayVariableForLoop, outputArrayRootVariableForLoop)); } } else { operationBuilder.append("0"); } operationBuilder.append(");"); } else { throw new IllegalArgumentException( "Unknown MappingConfigGenerator type found : " + generatorClass); } return operationBuilder.toString(); }
private String printStateStack() { String s = ""; @SuppressWarnings("unchecked") Stack<Integer> copy = (Stack<Integer>) state_stack.clone(); while (!copy.isEmpty()) { int c = copy.pop(); s += ('0' + c); s += " "; } return s; }
private String printOperatorStack() { String s = ""; @SuppressWarnings("unchecked") Stack<Character> copy = (Stack<Character>) operator_stack.clone(); while (!copy.isEmpty()) { char c = copy.pop(); s += c; s += " "; } return s; }
public static Stack<LCSCell> deepCloneCellStack(Stack<LCSCell> cellStack) { Stack<LCSCell> retStack = null; if (cellStack != null) { retStack = (Stack<LCSCell>) cellStack.clone(); try { for (int i = 0; i < cellStack.size(); i++) { retStack.add((LCSCell) cellStack.get(i).clone()); } } catch (CloneNotSupportedException cnse) { } } return retStack; }
public Stack stackUpdate(Stack old_stack) throws CodeCheckException { try { Stack new_stack = (Stack) old_stack.clone(); Object top1 = new_stack.pop(); if (top1 == ProcessStack.CAT1) { Object top2 = new_stack.pop(); if (top2 != ProcessStack.CAT1) throw new CodeCheckException("dup2_x2; second object is not CAT1"); Object top3 = new_stack.pop(); if (top3 == ProcessStack.CAT2) { new_stack.push(top2); new_stack.push(top1); new_stack.push(top3); new_stack.push(top2); new_stack.push(top1); } else { Object top4 = new_stack.pop(); if (top4 != ProcessStack.CAT1) throw new CodeCheckException("dup2_x2; fourth object is not CAT1"); new_stack.push(top2); new_stack.push(top1); new_stack.push(top4); new_stack.push(top3); new_stack.push(top2); new_stack.push(top1); } } else { Object top2 = new_stack.pop(); if (top2 == ProcessStack.CAT2) { new_stack.push(top1); new_stack.push(top2); new_stack.push(top1); } else { Object top3 = new_stack.pop(); if (top3 != ProcessStack.CAT1) throw new CodeCheckException("dup2_x2; object under CAT2, CAT1 is not CAT1"); new_stack.push(top1); new_stack.push(top3); new_stack.push(top2); new_stack.push(top1); } } return new_stack; } catch (EmptyStackException ese) { throw new CodeCheckException("dup2_x2; stack not deep enough"); } }
private Object extractListAsJson( ObjectToJsonConverter pConverter, List pList, Stack<String> pPath, int pLength) throws AttributeNotFoundException { List ret = new JSONArray(); for (int i = 0; i < pLength; i++) { Stack<String> path = (Stack<String>) pPath.clone(); try { ret.add(pConverter.extractObject(pList.get(i), path, true)); } catch (ValueFaultHandler.AttributeFilteredException exp) { // This element is filtered out, next one ... } } if (ret.isEmpty() && pLength > 0) { throw new ValueFaultHandler.AttributeFilteredException(); } return ret; }
/** * childPathList里面的每个元素为一个Stack<Integer>,栈顶存放了路径的起始节点,栈底则 存放了终止节点, 该方法用于getPaths(catId)之中 * * @param childPathList */ private List<Stack<Integer>> walkUp(List<Stack<Integer>> childPathList) { List<Stack<Integer>> results = new LinkedList<>(); for (Stack<Integer> subPath : childPathList) { int currentId = subPath.peek(); int depth = getDepth(currentId); if (depth <= 1) { results.add(subPath); } else { Set<Integer> parentIds = getParentIds(currentId); for (int parentId : parentIds) { Stack<Integer> path = (Stack<Integer>) subPath.clone(); path.push(parentId); results.add(path); } } } return results; }
@SuppressWarnings("unchecked") private DartNode makeCompletionNode(DartNode node) { Class<? extends DartNode> nodeClass = node.getClass(); CompletionNode newNode; if (nodeClass == DartMethodInvocation.class) { newNode = MethodInvocationCompleter.from((DartMethodInvocation) node); } else if (nodeClass == DartIdentifier.class) { newNode = IdentifierCompleter.from((DartIdentifier) node); } else if (nodeClass == DartPropertyAccess.class) { newNode = PropertyAccessCompleter.from((DartPropertyAccess) node); } else if (nodeClass == DartNewExpression.class) { newNode = NewExpressionCompleter.from((DartNewExpression) node); } else if (nodeClass == DartBlock.class) { newNode = BlockCompleter.from((DartBlock) node); } else if (nodeClass == DartTypeNode.class) { newNode = TypeCompleter.from((DartTypeNode) node); } else if (nodeClass == DartParameter.class) { newNode = ParameterCompleter.from((DartParameter) node); } else if (nodeClass == DartFunction.class) { newNode = FunctionCompleter.from((DartFunction) node); } else if (nodeClass == DartIfStatement.class) { newNode = IfCompleter.from((DartIfStatement) node); } else if (nodeClass == DartReturnStatement.class) { newNode = ReturnCompleter.from((DartReturnStatement) node); } else if (nodeClass == DartClass.class) { newNode = ClassCompleter.from((DartClass) node); } else if (nodeClass == DartSuperConstructorInvocation.class) { newNode = SuperConstructorInvocationCompleter.from((DartSuperConstructorInvocation) node); } else if (nodeClass == DartVariableStatement.class) { newNode = VariableStatementCompleter.from((DartVariableStatement) node); } else if (nodeClass == DartField.class) { newNode = FieldCompleter.from((DartField) node); } else if (nodeClass == DartTypeParameter.class) { newNode = TypeParameterCompleter.from((DartTypeParameter) node); } else { return node; } newNode.setCompletionParsingContext((Stack<Mark>) stack.clone()); return (DartNode) newNode; }
@SuppressWarnings("unchecked") private void init() { running_geometries = (Stack<VectorSpace.Geometry>) geometries.clone(); running_operations = (Stack<Operation>) operations.clone(); }
public LogException(java.util.Stack errors) { super(); errors_ = (java.util.Stack) errors.clone(); }