java.util.LinkedList#toString ( )源码实例Demo

下面列出了java.util.LinkedList#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: LinkedListTest.java
/**
 * toString contains toStrings of elements
 */
public void testToString() {
    LinkedList q = populatedQueue(SIZE);
    String s = q.toString();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
 
源代码2 项目: Android_Code_Arbiter   文件: CommandInjection.java
private String transferThroughList(String in, int index) {
    LinkedList<String> list = new LinkedList<String>();
    list.add(System.getenv("")); // taints the list
    list.clear(); // makes the list safe again
    list.add(1, "xx");
    list.addFirst(in); // can taint the list
    list.addLast("yy");
    list.push(in);
    return list.element() + list.get(index) + list.getFirst() + list.getLast()
            + list.peek() + list.peekFirst() + list.peekLast() + list.poll()
            + list.pollFirst() + list.pollLast() + list.pop() + list.remove()
            + list.remove(index) + list.removeFirst() + list.removeLast()
            + list.set(index, "safe") + list.toString();
}
 
源代码3 项目: j2objc   文件: LinkedListTest.java
/**
 * toString contains toStrings of elements
 */
public void testToString() {
    LinkedList q = populatedQueue(SIZE);
    String s = q.toString();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
 
源代码4 项目: java-cloudant   文件: QueryBuilder.java
private static String quoteSort(Sort[] sort) {
    LinkedList<String> sorts = new LinkedList<String>();
    for (Sort pair : sort) {
        sorts.add(String.format("{%s: %s}", Helpers.quote(pair.getName()), Helpers.quote(pair.getOrder().toString())));
    }
    return sorts.toString();
}
 
源代码5 项目: UVA   文件: UVA_11988 Broken Keyboard.java
public static void main(String[] args) throws IOException {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s;
    
    while((s=br.readLine())!=null){
        LinkedList a = new LinkedList();
        StringBuilder st = new StringBuilder();
        
        boolean homeKey = false;
        int homePressed=0;
        boolean endKey = true;
        
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='['){
                homeKey = true;
                homePressed=0;
                endKey = false;
            }else if(s.charAt(i)==']'){
                endKey = true;
                homeKey = false;
            }else{
                if(homeKey){
                    if(homePressed==0){
                        a.addFirst(s.charAt(i));
                        homePressed+=1;
                    }else if(homePressed!=0){
                        a.add(homePressed, s.charAt(i));
                        homePressed+=1;
                    }
                }else{
                    a.addLast(s.charAt(i));
                }
            }
        }
        
        String b = a.toString();
        for(int i=0;i<b.length();i++){
            if(b.charAt(i)!='['&&b.charAt(i)!=']'&&b.charAt(i)!=','&&b.charAt(i)!=' ')
                st.append(b.charAt(i));
        }
        
        System.out.println(st.toString());
    }    
}
 
源代码6 项目: gemfirexd-oss   文件: PathCompiler.java
public static Path tokenize(String path, Filter... filters) {
    notEmpty(path, "Path may not be null empty");
    path = path.trim();

    LinkedList<Filter> filterList = new LinkedList<Filter>(asList(filters));

    if (!path.startsWith("$")) {
        path = "$." + path;
    }

    String cacheKey = path + filterList.toString();
    Path p = cache.get(cacheKey);
    if(p != null){
       return p;
    }

    RootPathToken root = null;


    char[] chars = path.toCharArray();
    int i = 0;
    int positions;
    String fragment = "";

    do {
        char current = chars[i];

        switch (current) {
            case SPACE:
                throw new InvalidPathException("Space not allowed in path");
            case DOCUMENT:
                fragment = "$";
                i++;
                break;
            case BRACKET_OPEN:
                positions = fastForwardUntilClosed(chars, i);
                fragment = new String(chars, i, positions);
                i += positions;
                break;
            case PERIOD:
                i++;
                if (chars[i] == PERIOD) {
                    //This is a deep scan
                    fragment = "..";
                    i++;
                } else {
                    positions = fastForward(chars, i);
                    if (positions == 0) {
                        continue;

                    } else if (positions == 1 && chars[i] == '*') {
                        fragment = "[*]";
                    } else {
                        assertValidFieldChars(chars, i, positions);

                        fragment = PROPERTY_OPEN + new String(chars, i, positions) + PROPERTY_CLOSE;
                    }
                    i += positions;
                }
                break;
            case ANY:
                fragment = "[*]";
                i++;
                break;
            default:
                positions = fastForward(chars, i);

                fragment = PROPERTY_OPEN + new String(chars, i, positions) + PROPERTY_CLOSE;
                i += positions;
                break;
        }
        if (root == null) {
            root = (RootPathToken) PathComponentAnalyzer.analyze(fragment, filterList);
        } else {
            root.append(PathComponentAnalyzer.analyze(fragment, filterList));
        }

    } while (i < chars.length);

    Path pa = new CompiledPath(root);

    cache.put(cacheKey, pa);

    return pa;
}
 
源代码7 项目: gemfirexd-oss   文件: PathCompiler.java
public static Path tokenize(String path, Filter... filters) {
    notEmpty(path, "Path may not be null empty");
    path = path.trim();

    LinkedList<Filter> filterList = new LinkedList<Filter>(asList(filters));

    if (!path.startsWith("$")) {
        path = "$." + path;
    }

    String cacheKey = path + filterList.toString();
    Path p = cache.get(cacheKey);
    if(p != null){
       return p;
    }

    RootPathToken root = null;


    char[] chars = path.toCharArray();
    int i = 0;
    int positions;
    String fragment = "";

    do {
        char current = chars[i];

        switch (current) {
            case SPACE:
                throw new InvalidPathException("Space not allowed in path");
            case DOCUMENT:
                fragment = "$";
                i++;
                break;
            case BRACKET_OPEN:
                positions = fastForwardUntilClosed(chars, i);
                fragment = new String(chars, i, positions);
                i += positions;
                break;
            case PERIOD:
                i++;
                if (chars[i] == PERIOD) {
                    //This is a deep scan
                    fragment = "..";
                    i++;
                } else {
                    positions = fastForward(chars, i);
                    if (positions == 0) {
                        continue;

                    } else if (positions == 1 && chars[i] == '*') {
                        fragment = "[*]";
                    } else {
                        assertValidFieldChars(chars, i, positions);

                        fragment = PROPERTY_OPEN + new String(chars, i, positions) + PROPERTY_CLOSE;
                    }
                    i += positions;
                }
                break;
            case ANY:
                fragment = "[*]";
                i++;
                break;
            default:
                positions = fastForward(chars, i);

                fragment = PROPERTY_OPEN + new String(chars, i, positions) + PROPERTY_CLOSE;
                i += positions;
                break;
        }
        if (root == null) {
            root = (RootPathToken) PathComponentAnalyzer.analyze(fragment, filterList);
        } else {
            root.append(PathComponentAnalyzer.analyze(fragment, filterList));
        }

    } while (i < chars.length);

    Path pa = new CompiledPath(root);

    cache.put(cacheKey, pa);

    return pa;
}
 
源代码8 项目: JReFrameworker   文件: Engine.java
@SuppressWarnings("unused")
private static String getAccessModifiers(int access){
	LinkedList<String> modifiers = new LinkedList<String>();
	if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){
		modifiers.add("abstract");
	}
	if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){
		modifiers.add("annotation");
	}
	if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){
		modifiers.add("bridge");
	}
	if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){
		modifiers.add("deprecated");
	}
	if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){
		modifiers.add("enum");
	}
	if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){
		modifiers.add("final");
	}
	if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){
		modifiers.add("interface");
	}
	if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){
		modifiers.add("mandated");
	}
	if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){
		modifiers.add("native");
	}
	if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){
		modifiers.add("private");
	}
	if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){
		modifiers.add("protected");
	}
	if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){
		modifiers.add("public");
	}
	if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){
		modifiers.add("static");
	}
	if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){
		modifiers.add("strict");
	}
	if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){
		modifiers.add("super");
	}
	if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){
		modifiers.add("synchronized");
	}
	if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){
		modifiers.add("synthetic");
	}
	if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){
		modifiers.add("transient");
	}
	if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){
		modifiers.add("varargs");
	}
	if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){
		modifiers.add("volatile");
	}
	return modifiers.toString();
}
 
源代码9 项目: JReFrameworker   文件: Engine.java
@SuppressWarnings("unused")
private static String getAccessModifiers(int access){
	LinkedList<String> modifiers = new LinkedList<String>();
	if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){
		modifiers.add("abstract");
	}
	if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){
		modifiers.add("annotation");
	}
	if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){
		modifiers.add("bridge");
	}
	if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){
		modifiers.add("deprecated");
	}
	if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){
		modifiers.add("enum");
	}
	if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){
		modifiers.add("final");
	}
	if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){
		modifiers.add("interface");
	}
	if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){
		modifiers.add("mandated");
	}
	if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){
		modifiers.add("native");
	}
	if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){
		modifiers.add("private");
	}
	if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){
		modifiers.add("protected");
	}
	if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){
		modifiers.add("public");
	}
	if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){
		modifiers.add("static");
	}
	if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){
		modifiers.add("strict");
	}
	if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){
		modifiers.add("super");
	}
	if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){
		modifiers.add("synchronized");
	}
	if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){
		modifiers.add("synthetic");
	}
	if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){
		modifiers.add("transient");
	}
	if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){
		modifiers.add("varargs");
	}
	if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){
		modifiers.add("volatile");
	}
	return modifiers.toString();
}
 
源代码10 项目: rice   文件: SimplePropositionTypeService.java
/**
 * Translates the parameters on the given proposition definition to create an expression for evaluation.
 * The proposition parameters are defined in a reverse-polish notation so a stack is used for
 * evaluation purposes.
 * 
 * @param propositionDefinition the proposition definition to translate
 * 
 * @return the translated expression for the given proposition, this
 * expression, when evaluated, will return a Boolean.
 */
protected Expression<Boolean> translateToExpression(PropositionDefinition propositionDefinition) {
	LinkedList<Expression<? extends Object>> stack = new LinkedList<Expression<? extends Object>>();
	for (PropositionParameter parameter : propositionDefinition.getParameters()) {
		PropositionParameterType parameterType = PropositionParameterType.fromCode(parameter.getParameterType());
		if (parameterType == PropositionParameterType.CONSTANT) {
			// TODO - need some way to define data type on the prop parameter as well?  Not all constants will actually be String values!!!
			stack.addFirst(new ConstantExpression<String>(parameter.getValue()));
		} else if (parameterType == PropositionParameterType.FUNCTION) {
			String functionId = parameter.getValue();
			FunctionDefinition functionDefinition = functionRepositoryService.getFunction(functionId);
			if (functionDefinition == null) {
				throw new RepositoryDataException("Unable to locate function with the given id: " + functionId);
			}
			FunctionTypeService functionTypeService = typeResolver.getFunctionTypeService(functionDefinition);
			Function function = functionTypeService.loadFunction(functionDefinition);
			// TODO throw an exception if function is null?
			List<FunctionParameterDefinition> parameters = functionDefinition.getParameters();
			if (stack.size() < parameters.size()) {
				throw new RepositoryDataException("Failed to initialize custom function '" + functionDefinition.getNamespace() + " " + functionDefinition.getName() +
						"'.  There were only " + stack.size() + " values on the stack but function requires at least " + parameters.size());
			}
			List<Expression<? extends Object>> arguments = new ArrayList<Expression<? extends Object>>();
			// work backward through the list to match params to the stack
			for (int index = parameters.size() - 1; index >= 0; index--) {
				FunctionParameterDefinition parameterDefinition = parameters.get(index);
				// TODO need to check types here? expression object probably needs a getType on it so that we can confirm that the types will be compatible?
                   parameterDefinition.getParameterType();
				Expression<? extends Object> argument = stack.removeFirst();
				arguments.add(argument);
			}

               String[] parameterTypes = getFunctionParameterTypes(functionDefinition);
			stack.addFirst(new FunctionExpression(function, parameterTypes, arguments, getComparisonOperatorService()));

		} else if (parameterType == PropositionParameterType.OPERATOR) {
			ComparisonOperator operator = ComparisonOperator.fromCode(parameter.getValue());
			if (stack.size() < 2) {
				throw new RepositoryDataException("Failed to initialize expression for comparison operator " +
                           operator + " because a sufficient number of arguments was not available on the stack.  "
                           + "Current contents of stack: " + stack.toString());
			}
			Expression<? extends Object> rhs = stack.removeFirst();
			Expression<? extends Object> lhs = stack.removeFirst();
			stack.addFirst(new BinaryOperatorExpression(operator, lhs, rhs));
		} else if (parameterType == PropositionParameterType.TERM) {
			String termId = parameter.getValue();

			TermDefinition termDefinition = getTermRepositoryService().getTerm(termId);
			if (termDefinition == null) { throw new RepositoryDataException("unable to load term with id " + termId);}
			Term term = translateTermDefinition(termDefinition);
			
			stack.addFirst(new TermExpression(term));
		}
	}
	if (stack.size() != 1) {
		throw new RepositoryDataException("Final contents of expression stack are incorrect, there should only be one entry but was " + stack.size() +".  Current contents of stack: " + stack.toString());
	}
	return new BooleanValidatingExpression(stack.removeFirst());
}