public StringBuffer computeValue(Vector referenceList) throws SemanticException {

    ASTValue aValue = (ASTValue) getChildOfType(ParserTreeConstants.JJTVALUE);
    return aValue.computeValue(referenceList);
  }
Example #2
0
  public void handleNode(MibNode aNode) throws IOException {

    // Check if the node is a nested group or not. A nested group
    // has some children but is not a associated.
    if (aNode.isGroup() || aNode.hasNestedGroups()) {
      // The node is a nested group !
      //
      handleNestedGroups(aNode);
      return;
    }
    // Check if the node is a table or not. A table has some children
    // but is not a group.
    if (aNode.isTable()) {
      // The node is a table !
      //
      handleTable(aNode);
      return;
    }

    // Name of the symbol
    //
    String varName = aNode.getSymbolName();

    // Get the object definition associated to the node
    //
    ASTObjectTypeDefinition definition = aNode.getObjectType();
    if (definition == null) return;
    // get the syntax ...
    //
    ASTNamedType syntax = definition.getSyntax();
    String strSyntax = "";

    // Get the default MIB variable value
    //
    ASTValue defValue = definition.getDefValue();

    String init = "";
    if (syntax.isEnumeratedType()) {
      // get the access mode of the node
      //
      EnumGenerator enumgen =
          new EnumGenerator(manager, varName, syntax.getEnumeratedDef(), context);
      strSyntax = enumgen.getTypeName();

      // Now get the SNMP syntax in order to get a valid init value ...
      //  - if a default value is defined, just take it
      //  - otherwise, get a valid init value defined in the syntax mapper
      //

      // There is a default value for this variable.
      //
      if (defValue != null) {
        init = defValue.getDefValInitializer(strSyntax, syntax, varName);
      }
      // There is no default value for this variable or the default value cannot be resolved.
      //
      if ((defValue == null) || (init.equals(""))) {
        init = " = new " + strSyntax.trim() + "()";
      }

      aNode.setEnumerated(true);
      aNode.setEnumeratedType(strSyntax);
    } else {
      // Get the real syntax to use for the node
      //
      strSyntax = syntax.getMbeanSyntax();

      // Now get the SNMP syntax in order to get a valid init value ...
      //  - if a default value is defined, just take it
      //  - otherwise, get a valid init value defined in the syntax mapper
      //

      // There is a default value for this variable.
      //
      if (defValue != null) {
        init = defValue.getDefValInitializer(strSyntax, syntax, varName);
      }
      // There is no default value for this variable or the default value cannot be resolved.
      //
      if ((defValue == null) || (init.equals(""))) {
        init = SyntaxMapper.getInitializer(syntax.getSnmpSyntax());
      }
    }

    // Add a Java variable for representing the snmp variable ...
    //
    long length = syntax.getFixedLength();
    aNode.setFixedLength(length);
    addCacheVar(aNode, strSyntax, length, init, varName);

    // Generate getter and setter
    //
    addAccessors(aNode, strSyntax, varName);
  }