Package org.dtk.analysis.script.node

Examples of org.dtk.analysis.script.node.ObjectLiteral


   */
  @Override
  protected List<String> retrieveConfigurationKeys(Node node) {   
    List<String> configurationKeys = new ArrayList<String>();

    ObjectLiteral objLiteral = configurationLiterals.get(node);
       
    if (objLiteral != null) {     
      configurationKeys = objLiteral.getKeys();
    }
   
    return configurationKeys;
  }
View Full Code Here


   */
  @Override
  protected Object retrieveConfigurationValue(Node node, String key) {
    Object configuationValue = null;
   
    ObjectLiteral objLiteral = configurationLiterals.get(node);
   
    if (objLiteral != null) {
      configuationValue = objLiteral.getValue(key);               
    }
     
    return configuationValue;
  }   
View Full Code Here

   * @param configuration - Configuration declaration node
   * @param literal - Object literal node
   */
  protected void addConfigurationLiteral(Node configuration, Node literal) {
    try {
      configurationLiterals.put(configuration, new ObjectLiteral(literal));
    } catch (InvalidLiteralNode e) {
      logger.info("Invalid configuration literal discovered: " + literal.getType());
    }
  }
View Full Code Here

   * @param packages - Module packages list
   */ 
  protected void updateInternalPathsConfig(ArrayLiteral packages) {
    for(Object packageInfo: packages.getValueList()) {
      if (packageInfo instanceof ObjectLiteral) {
        ObjectLiteral packageInfoLit = (ObjectLiteral) packageInfo;
        Object packagePath = packageInfoLit.getValue(DojoConfigAttrs.PACKAGES_LOCATION_CONFIG_FLAG),
           packageName = packageInfoLit.getValue(DojoConfigAttrs.PACKAGES_NAME_CONFIG_FLAG);
       
        if (packagePath instanceof String && packageName instanceof String) {
          modulePaths.put((String) packageName, (String) packagePath);
        }
      }
View Full Code Here

  }     
 
  @Test(expected=InvalidLiteralNode.class)
  public void throwsExceptionWhenPassingNonLiteralNode() throws InvalidLiteralNode {         
    Node node = new Node(Token.SCRIPT);
    ObjectLiteral lit = new ObjectLiteral(node);   
  }
View Full Code Here

    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(scriptSource, "script", 0);
   
    return new ObjectLiteral(ast.getFirstChild().getFirstChild().getFirstChild());
  }
View Full Code Here

    }
  }
 
  @Test
  public void canParseEmptyLiteralNode() throws InvalidLiteralNode {   
    ObjectLiteral lit = getLiteralNode("{}");
    assertEquals(Collections.EMPTY_LIST, lit.getKeys());
 
View Full Code Here

    assertEquals(Collections.EMPTY_LIST, lit.getKeys());
 

  @Test
  public void detectsStringValuesInObjectLiteral() throws InvalidLiteralNode 
    ObjectLiteral lit = getLiteralNode("{ key: 'value', an: 'other'}");   
    assertEquals(Arrays.asList("key", "an"), lit.getKeys());
    assertValues(lit, getPrepopulatedMap("key", "value", "an", "other"));   
  }
View Full Code Here

    assertValues(lit, getPrepopulatedMap("key", "value", "an", "other"));   
  }
 
  @Test
  public void detectsBooleanValuesInObjectLiteral() throws InvalidLiteralNode 
    ObjectLiteral lit = getLiteralNode("{ key: true, an: false}");   
    assertEquals(Arrays.asList("key", "an"), lit.getKeys());
    assertValues(lit, getPrepopulatedMap("key", Boolean.TRUE, "an", Boolean.FALSE));   
  }
View Full Code Here

    assertValues(lit, getPrepopulatedMap("key", Boolean.TRUE, "an", Boolean.FALSE));   
  }
 
  @Test
  public void detectsNumberValuesInObjectLiteral() throws InvalidLiteralNode {         
    ObjectLiteral lit = getLiteralNode("{ key: 0, an: 1}");   
    assertEquals(Arrays.asList("key", "an"), lit.getKeys());
    assertValues(lit, getPrepopulatedMap("key", 0.0, "an", 1.0));
  }
View Full Code Here

TOP

Related Classes of org.dtk.analysis.script.node.ObjectLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.