当前位置: 首页>>代码示例>>Java>>正文


Java SwitchEntryStmt.getLabel方法代码示例

本文整理汇总了Java中com.github.javaparser.ast.stmt.SwitchEntryStmt.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchEntryStmt.getLabel方法的具体用法?Java SwitchEntryStmt.getLabel怎么用?Java SwitchEntryStmt.getLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.javaparser.ast.stmt.SwitchEntryStmt的用法示例。


在下文中一共展示了SwitchEntryStmt.getLabel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override
public void visit(final SwitchEntryStmt n, final Object arg) {
    printer.printLn("SwitchEntryStmt");
    printJavaComment(n.getComment(), arg);
    if (n.getLabel() != null) {
        printer.print("case ");
        n.getLabel().accept(this, arg);
        printer.print(":");
    } else {
        printer.print("default:");
    }
    printer.printLn();
    printer.indent();
    if (n.getStmts() != null) {
        for (final Statement s : n.getStmts()) {
            s.accept(this, arg);
            printer.printLn();
        }
    }
    printer.unindent();
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:22,代码来源:ASTDumpVisitor.java

示例2: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override
public JCTree visit(final SwitchEntryStmt n, final Object arg) {
    //ARG0: JCExpression pat
    JCExpression arg0 = null;
    if (n.getLabel() != null) {
        arg0 = (JCExpression) n.getLabel().accept(this, arg);
    }

    //ARG1: List<JCStatement> stats
    List<JCStatement> arg1 = List.<JCStatement>nil();
    if (n.getStmts() != null) {
        for (final Statement s : n.getStmts()) {
            arg1 = arg1.append((JCStatement) s.accept(this, arg));
        }
    }

    return new AJCCase(make.Case(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:19,代码来源:JavaParser2JCTree.java

示例3: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchEntryStmt n, final Object arg) {
printJavaComment(n.getComment(), arg);
if (n.getLabel() != null) {
    printer.print("case ");
    n.getLabel().accept(this, arg);
    printer.print(":");
} else {
    printer.print("default:");
}
printer.printLn();
printer.indent();
if (n.getStmts() != null) {
    for (final Statement s : n.getStmts()) {
	s.accept(this, arg);
	printer.printLn();
    }
}
printer.unindent();
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:20,代码来源:DumpVisitor.java

示例4: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchEntryStmt n, final Object arg) {
	printJavaComment(n.getComment(), arg);
	if (n.getLabel() != null) {
		printer.print("case ");
		n.getLabel().accept(this, arg);
		printer.print(":");
	} else {
		printer.print("default:");
	}
	printer.printLn();
	printer.indent();
	if (n.getStmts() != null) {
		for (final Statement s : n.getStmts()) {
			s.accept(this, arg);
			printer.printLn();
		}
	}
	printer.unindent();
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:20,代码来源:DumpVisitor.java

示例5: parseSwitchStatement

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
/**
 *
 * @param switchStmt
 *      a github javaparser SwithStatement
 * @param attributes
 *      the list of attributes of the class,
 *      to potentially get a type from the name
 * @param bd
 *      a body declaration
 * @return
 *      a SwitchStatement structure
 */
private SwitchStatement parseSwitchStatement(SwitchStmt switchStmt, List<Attribute> attributes, BodyDeclaration bd) {
    SwitchStatement switchStatement = new SwitchStatement();
    switchStatement.setCondition(parseExpression(switchStmt.getSelector(), attributes, bd.getBeginLine()));
    if (switchStmt.getEntries() != null) {
        List<CaseClause> caseClauses = new ArrayList<>();
        for (SwitchEntryStmt switchEntry : switchStmt.getEntries()) {
            CaseClause caseClause = new CaseClause();
            List<Expr> conditions = new ArrayList<>();
            if (switchEntry.getLabel() != null) {
                conditions.add(parseExpression(switchEntry.getLabel(), attributes, bd.getBeginLine()));
                caseClause.setConditions(conditions);
            } else {
                if (switchEntry.getStmts() != null) {
                    switchStatement.setDefaultStmt(parseListStmt(switchEntry.getStmts(), attributes, bd));
                }
            }
            if (switchEntry.getStmts() != null) {
                List<Stmt> body = new ArrayList<>();
                body.addAll(parseListStmt(switchEntry.getStmts(), attributes, bd));
                caseClause.setBody(body);
            }
            caseClauses.add(caseClause);
        }
        switchStatement.setCaseClauses(caseClauses);
    }
    return switchStatement;
}
 
开发者ID:DevMine,项目名称:parsers,代码行数:40,代码来源:Parser.java

示例6: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchEntryStmt n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getLabel() != null) {
		n.getLabel().accept(this, arg);
	}
	if (n.getStmts() != null) {
		for (final Statement s : n.getStmts()) {
			s.accept(this, arg);
		}
	}
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:12,代码来源:VoidVisitorAdapter.java

示例7: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchEntryStmt n, final A arg) {
    jw.write(n); 
    visitComment(n.getComment(), arg);
    if (n.getLabel() != null) {
        n.getLabel().accept(this, arg);
    }
    if (n.getStmts() != null) {
        for (final Statement s : n.getStmts()) {
            s.accept(this, arg);
        }
    }
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:13,代码来源:JsonVisitorAdapter.java

示例8: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public Node visit(final SwitchEntryStmt n, final A arg) {
	if (n.getLabel() != null) {
		n.setLabel((Expression) n.getLabel().accept(this, arg));
	}
	final List<Statement> stmts = n.getStmts();
	if (stmts != null) {
		for (int i = 0; i < stmts.size(); i++) {
			stmts.set(i, (Statement) stmts.get(i).accept(this, arg));
		}
		removeNulls(stmts);
	}
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:14,代码来源:ModifierVisitorAdapter.java

示例9: visit

import com.github.javaparser.ast.stmt.SwitchEntryStmt; //导入方法依赖的package包/类
@Override public Node visit(final SwitchEntryStmt n, final A arg) {
	visitComment(n, arg);
	if (n.getLabel() != null) {
		n.setLabel((Expression) n.getLabel().accept(this, arg));
	}
	final List<Statement> stmts = n.getStmts();
	if (stmts != null) {
		for (int i = 0; i < stmts.size(); i++) {
			stmts.set(i, (Statement) stmts.get(i).accept(this, arg));
		}
		removeNulls(stmts);
	}
	return n;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:15,代码来源:ModifierVisitorAdapter.java


注:本文中的com.github.javaparser.ast.stmt.SwitchEntryStmt.getLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。