public static Identifier identifier(String name) { return new Identifier(name); }
@Override protected Void visitIdentifier(Identifier node, Integer indentLevel) { QualifiedName resolved = resolvedNameReferences.get(node); String resolvedName = ""; if (resolved != null) { resolvedName = "=>" + resolved.toString(); } print(indentLevel, "Identifier[" + node.getValue() + resolvedName + "]"); return null; }
@Override protected String visitIdentifier(Identifier node, Void context) { if (!node.isDelimited()) { return node.getValue(); } else { return '"' + node.getValue().replace("\"", "\"\"") + '"'; } }
name = QualifiedName.of(((Identifier) expression).getValue()); field = Optional.of(new Identifier(getLast(name.getOriginalParts())));
/** * extracts a variable name from the provided expression * @param e * @return */ private String getVariableName(Expression e){ if(e instanceof DereferenceExpression){ // parse columns like 'reference.field' return SelectParser.visitDereferenceExpression((DereferenceExpression)e); }else if (e instanceof Identifier){ return ((Identifier)e).getName(); } else return e.toString(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Use use = (Use) o; if (!catalog.equals(use.catalog)) { return false; } if (!schema.equals(use.schema)) { return false; } return true; }
@Override protected String visitIdentifier(Identifier node, Void context) { if (!node.isDelimited()) { return node.getValue(); } else { return '"' + node.getValue().replace("\"", "\"\"") + '"'; } }
private void con(){ JInputJoystick joystick = new JInputJoystick(Controller.Type.STICK); while (joystick.isControllerConnected()) { // Go trough all components of the controller. Component[] components = joystick.getComponents(); for(int i=0; i < components.length; i++) { Component component = components[i]; Identifier componentIdentifier = component.getIdentifier(); // Buttons if(componentIdentifier.getName().matches("^[0-9]*$")){ // If the component identifier name contains only numbers, then this is a button. // Is button pressed? if(component.getPollData() != 0.0f) { txt.setText("Button got pressed!") } } } // We have to give processor some rest. try { Thread.sleep(25); } catch (InterruptedException ex) { Logger.getLogger(JoystickTest.class.getName()).log(Level.SEVERE, null, ex); } } txt.setText("Controller not connected"); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Use use = (Use) o; if (!catalog.equals(use.catalog)) { return false; } if (!schema.equals(use.schema)) { return false; } return true; }
public static Identifier quotedIdentifier(String name) { return new Identifier(name, true); }
@Override public Expression rewriteIdentifier(Identifier node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new SymbolReference(node.getValue()); }
public static String visitDereferenceExpression(DereferenceExpression node){ if(node.getBase() instanceof Identifier) { return ((Identifier)node.getBase()).getName()/*.getValue()*/+"."+node.getFieldName()/*.getValue()*/; }else return visitDereferenceExpression((DereferenceExpression)node.getBase())+"."+node.getFieldName()/*.getValue()*/; }
public static Expression from(QualifiedName name) { Expression result = null; for (String part : name.getParts()) { if (result == null) { result = new Identifier(part); } else { result = new DereferenceExpression(result, new Identifier(part)); } } return result; }
@Override protected Void visitIdentifier(Identifier node, ImmutableSet.Builder<QualifiedName> builder) { builder.add(QualifiedName.of(node.getValue())); return null; } }
@Override protected Column visitExpression(Expression node, QueryState state){ if( node instanceof Identifier){ return createColumn( ((Identifier)node).getName()/*.getValue()*/, null, state, "select.+", ".+from"); }else if(node instanceof DereferenceExpression){ column = visitDereferenceExpression((DereferenceExpression)fc.getArguments().get(0) ); else { column = ((Identifier)fc.getArguments().get(0)).getName()/*.getValue()*/;
private static Identifier input(String symbol) { return new Identifier(symbol); } }
private void validateColumnAliases(List<Identifier> columnAliases, int sourceColumnSize) { if (columnAliases.size() != sourceColumnSize) { throw new SemanticException( MISMATCHED_COLUMN_ALIASES, columnAliases.get(0), "Column alias list has %s entries but subquery has %s columns", columnAliases.size(), sourceColumnSize); } Set<String> names = new HashSet<>(); for (Identifier identifier : columnAliases) { if (names.contains(identifier.getValue().toLowerCase(ENGLISH))) { throw new SemanticException(DUPLICATE_COLUMN_NAME, identifier, "Column name '%s' specified more than once", identifier.getValue()); } names.add(identifier.getValue().toLowerCase(ENGLISH)); } }