/** * 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(); }
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"); }
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()*/; }
@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()*/;
orderKey = ((Identifier)si.getSortKey()).getName(); //.getValue(); }else { state.addException("Order statement with type '"+si.getSortKey().getClass().getName()+"' is not supported");
col2 = ((Identifier)compareExp.getRight()).getName(); //.getValue();