本文整理汇总了Java中antlr.collections.AST.getText方法的典型用法代码示例。如果您正苦于以下问题:Java AST.getText方法的具体用法?Java AST.getText怎么用?Java AST.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类antlr.collections.AST
的用法示例。
在下文中一共展示了AST.getText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveFunctionArgument
import antlr.collections.AST; //导入方法依赖的package包/类
private String resolveFunctionArgument(AST argumentNode) {
final String nodeText = argumentNode.getText();
final String adjustedText;
if ( nodeText.contains( Template.TEMPLATE ) ) {
// we have a SQL order-by fragment
adjustedText = adjustTemplateReferences( nodeText );
}
else if ( nodeText.startsWith( "{" ) && nodeText.endsWith( "}" ) ) {
columnReferences.add( nodeText.substring( 1, nodeText.length() - 1 ) );
return nodeText;
}
else {
adjustedText = nodeText;
// because we did not process the node text, we need to attempt to find any column references
// contained in it.
// NOTE : uses regex for the time being; we should check the performance of this
Pattern pattern = Pattern.compile( "\\{(.*)\\}" );
Matcher matcher = pattern.matcher( adjustedText );
while ( matcher.find() ) {
columnReferences.add( matcher.group( 1 ) );
}
}
return adjustedText;
}
示例2: nodeToString
import antlr.collections.AST; //导入方法依赖的package包/类
public String nodeToString(AST ast, boolean showClassName) {
if ( ast == null ) {
return "{node:null}";
}
StringBuilder buf = new StringBuilder();
buf.append( "[" ).append( getTokenTypeName( ast.getType() ) ).append( "] " );
if ( showClassName ) {
buf.append( StringHelper.unqualify( ast.getClass().getName() ) ).append( ": " );
}
buf.append( "'" );
String text = ast.getText();
if ( text == null ) {
text = "{text:null}";
}
appendEscapedMultibyteChars( text, buf );
buf.append( "'" );
if ( ast instanceof DisplayableNode ) {
DisplayableNode displayableNode = (DisplayableNode) ast;
// Add a space before the display text.
buf.append( " " ).append( displayableNode.getDisplayText() );
}
return buf.toString();
}
示例3: isNonQualifiedPropertyRef
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected boolean isNonQualifiedPropertyRef(AST ident) {
final String identText = ident.getText();
if ( currentFromClause.isFromElementAlias( identText ) ) {
return false;
}
List fromElements = currentFromClause.getExplicitFromElements();
if ( fromElements.size() == 1 ) {
final FromElement fromElement = (FromElement) fromElements.get( 0 );
try {
LOG.tracev( "Attempting to resolve property [{0}] as a non-qualified ref", identText );
return fromElement.getPropertyMapping( identText ).toType( identText ) != null;
}
catch (QueryException e) {
// Should mean that no such property was found
}
}
return false;
}
示例4: generateNamedParameter
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected AST generateNamedParameter(AST delimiterNode, AST nameNode) throws SemanticException {
String name = nameNode.getText();
trackNamedParameterPositions( name );
// create the node initially with the param name so that it shows
// appropriately in the "original text" attribute
ParameterNode parameter = (ParameterNode) astFactory.create( NAMED_PARAM, name );
parameter.setText( "?" );
NamedParameterSpecification paramSpec = new NamedParameterSpecification(
delimiterNode.getLine(),
delimiterNode.getColumn(),
name
);
parameter.setHqlParameterSpecification( paramSpec );
parameters.add( paramSpec );
return parameter;
}
示例5: resolveIdent
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected AST resolveIdent(AST ident) {
/*
* Semantic action used during recognition of an identifier. This identifier might be a column name, it might
* be a property name.
*/
String text = ident.getText();
SqlValueReference[] sqlValueReferences;
try {
sqlValueReferences = context.getColumnMapper().map( text );
}
catch( Throwable t ) {
sqlValueReferences = null;
}
if ( sqlValueReferences == null || sqlValueReferences.length == 0 ) {
return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, makeColumnReference( text ) );
}
else if ( sqlValueReferences.length == 1 ) {
return processSqlValueReference( sqlValueReferences[0] );
}
else {
final AST root = getASTFactory().create( OrderByTemplateTokenTypes.IDENT_LIST, "{ident list}" );
for ( SqlValueReference sqlValueReference : sqlValueReferences ) {
root.addChild( processSqlValueReference( sqlValueReference ) );
}
return root;
}
}
示例6: setPropertyNameAndPath
import antlr.collections.AST; //导入方法依赖的package包/类
private void setPropertyNameAndPath(AST parent) {
if ( isDotNode( parent ) ) {
DotNode dotNode = (DotNode) parent;
AST lhs = dotNode.getFirstChild();
AST rhs = lhs.getNextSibling();
propertyName = rhs.getText();
propertyPath = propertyPath + "." + propertyName; // Append the new property name onto the unresolved path.
dotNode.propertyPath = propertyPath;
LOG.debugf( "Unresolved property path is now '%s'", dotNode.propertyPath );
}
else {
LOG.debugf( "Terminal getPropertyPath = [%s]", propertyPath );
}
}
示例7: initializeMethodNode
import antlr.collections.AST; //导入方法依赖的package包/类
public void initializeMethodNode(AST name, boolean inSelect) {
name.setType( SqlTokenTypes.METHOD_NAME );
String text = name.getText();
// Use the lower case function name.
methodName = text.toLowerCase();
// Remember whether we're in a SELECT clause or not.
this.inSelect = inSelect;
}
示例8: collectionProperty
import antlr.collections.AST; //导入方法依赖的package包/类
private void collectionProperty(AST path, AST name) throws SemanticException {
if ( path == null ) {
throw new SemanticException( "Collection function " + name.getText() + " has no path!" );
}
SqlNode expr = (SqlNode) path;
Type type = expr.getDataType();
LOG.debugf( "collectionProperty() : name=%s type=%s", name, type );
resolveCollectionProperty( expr );
}
示例9: toPathText
import antlr.collections.AST; //导入方法依赖的package包/类
private String toPathText(AST node) {
final String text = node.getText();
if ( text.equals( "." )
&& node.getFirstChild() != null
&& node.getFirstChild().getNextSibling() != null
&& node.getFirstChild().getNextSibling().getNextSibling() == null ) {
return toPathText( node.getFirstChild() ) + '.' + toPathText( node.getFirstChild().getNextSibling() );
}
return text;
}
示例10: buildTraceNodeName
import antlr.collections.AST; //导入方法依赖的package包/类
private String buildTraceNodeName(AST tree) {
return tree == null
? "???"
: tree.getText() + " [" + printer.getTokenTypeName( tree.getType() ) + "]";
}
示例11: visit
import antlr.collections.AST; //导入方法依赖的package包/类
public void visit(AST node) {
// Flatten this level of the tree if it has no children
boolean flatten = /*true*/ false;
AST node2;
for (node2 = node; node2 != null; node2 = node2.getNextSibling()) {
if (node2.getFirstChild() != null) {
flatten = false;
break;
}
}
for (node2 = node; node2 != null; node2 = node2.getNextSibling()) {
if (!flatten || node2 == node) {
tabs();
}
if (node2.getText() == null) {
System.out.print("nil");
}
else {
System.out.print(node2.getText());
}
System.out.print(" [" + node2.getType() + "] ");
if (flatten) {
System.out.print(" ");
}
else {
System.out.println("");
}
if (node2.getFirstChild() != null) {
level++;
visit(node2.getFirstChild());
level--;
}
}
if (flatten) {
System.out.println("");
}
}
示例12: addFromElement
import antlr.collections.AST; //导入方法依赖的package包/类
/**
* Adds a new from element to the from node.
*
* @param path The reference to the class.
* @param alias The alias AST.
*
* @return FromElement - The new FROM element.
*/
public FromElement addFromElement(String path, AST alias) throws SemanticException {
// The path may be a reference to an alias defined in the parent query.
String classAlias = ( alias == null ) ? null : alias.getText();
checkForDuplicateClassAlias( classAlias );
FromElementFactory factory = new FromElementFactory( this, null, path, classAlias, null, false );
return factory.addFromElement();
}
示例13: createFromJoinElement
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected void createFromJoinElement(
AST path,
AST alias,
int joinType,
AST fetchNode,
AST propertyFetch,
AST with) throws SemanticException {
boolean fetch = fetchNode != null;
if ( fetch && isSubQuery() ) {
throw new QueryException( "fetch not allowed in subquery from-elements" );
}
// The path AST should be a DotNode, and it should have been evaluated already.
if ( path.getType() != SqlTokenTypes.DOT ) {
throw new SemanticException( "Path expected for join!" );
}
DotNode dot = (DotNode) path;
JoinType hibernateJoinType = JoinProcessor.toHibernateJoinType( joinType );
dot.setJoinType( hibernateJoinType ); // Tell the dot node about the join type.
dot.setFetch( fetch );
// Generate an explicit join for the root dot node. The implied joins will be collected and passed up
// to the root dot node.
dot.resolve( true, false, alias == null ? null : alias.getText() );
final FromElement fromElement;
if ( dot.getDataType() != null && dot.getDataType().isComponentType() ) {
if ( dot.getDataType().isAnyType() ) {
throw new SemanticException( "An AnyType attribute cannot be join fetched" );
// ^^ because the discriminator (aka, the "meta columns") must be known to the SQL in
// a non-parameterized way.
}
FromElementFactory factory = new FromElementFactory(
getCurrentFromClause(),
dot.getLhs().getFromElement(),
dot.getPropertyPath(),
alias == null ? null : alias.getText(),
null,
false
);
fromElement = factory.createComponentJoin( (ComponentType) dot.getDataType() );
}
else {
fromElement = dot.getImpliedJoin();
fromElement.setAllPropertyFetch( propertyFetch != null );
if ( with != null ) {
if ( fetch ) {
throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
}
handleWithFragment( fromElement, with );
}
}
if ( LOG.isDebugEnabled() ) {
LOG.debug( "createFromJoinElement() : " + getASTPrinter().showAsString( fromElement, "-- join tree --" ) );
}
}