Package org.jdom

Examples of org.jdom.Attribute


        // --------------------------------
        List idents = selectElement.getChildren();
        Iterator identIter = idents.iterator();
        while ( identIter.hasNext() ) {
            Element dataElement = (Element) identIter.next();
            Attribute dataType = dataElement.getAttribute(TagNames.Attributes.TYPE);
            // add the dataType of the element to the list containing dataTypes
            ElementSymbol nodeID = new ElementSymbol(dataElement.getText());
            Class nodeType = (Class) TagNames.TYPE_MAP.get(dataType.getValue());
            if (nodeType == null)  {
                throw new JDOMException("Unknown class for type \"" + dataType.getValue() + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
            }
            nodeID.setType(nodeType);
            select.addSymbol(nodeID);
        }
View Full Code Here


                    rowElement.addContent(cellElement);
                }
                tableElement.addContent(rowElement);
                rowCount++;
            }
            Attribute rowCountAttribute = new Attribute(TagNames.Attributes.TABLE_ROW_COUNT,
                                                        Integer.toString(rowCount));
            Attribute columnCountAttribute = new Attribute(TagNames.Attributes.TABLE_COLUMN_COUNT,
                                                           Integer.toString(colCount));
            tableElement.setAttribute(rowCountAttribute);
            tableElement.setAttribute(columnCountAttribute);
        } catch ( SQLException e ) {
            // error while reading results
View Full Code Here

                    rowElement.addContent(cellElement);
                }
                tableElement.addContent(rowElement);
                rowCount++;
            }
            Attribute rowCountAttribute = new Attribute(TagNames.Attributes.TABLE_ROW_COUNT,
                                                        Integer.toString(rowCount));
            Attribute columnCountAttribute = new Attribute(TagNames.Attributes.TABLE_COLUMN_COUNT,
                                                           Integer.toString(colCount));
            tableElement.setAttribute(rowCountAttribute);
            tableElement.setAttribute(columnCountAttribute);
        } catch ( SQLException e ) {
            // error while reading results
View Full Code Here

        // ---------------------------------
        // Create the DISTINCT attribute ...
        // ---------------------------------
        boolean distinct = select.isDistinct();
        if ( distinct ) {
            Attribute distinctAttribute = new Attribute(TagNames.Attributes.DISTINCT, "true"); //$NON-NLS-1$
            selectElement.setAttribute(distinctAttribute);
        } // else default is false so no need

        // ----------------------------------
        // Create the STAR attribute ...
        // ----------------------------------
        if ( select.isStar() ) {
            Attribute starAttribute = new Attribute(TagNames.Attributes.STAR, "true"); //$NON-NLS-1$
            selectElement.setAttribute(starAttribute);
        }

        // --------------------------------
        // Create the DATANODE elements ...
        // --------------------------------
        int col = 0;
        Iterator iter = select.getSymbols().iterator();
        while ( iter.hasNext() ) {
            Element dataElement = new Element(TagNames.Elements.DATA_ELEMENT);
            ElementSymbol symbol = (ElementSymbol) iter.next();
            String elementName = symbol.getName();
            Attribute dataType = null;
            try {
                dataType = new Attribute(TagNames.Attributes.TYPE, rmdata.getColumnTypeName(++col));
            } catch ( SQLException e ) {
                //
            }
            dataElement.setAttribute(dataType);
            dataElement.setText(elementName);
View Full Code Here

      Element queryElement = new Element(TagNames.Elements.QUERY);
      queryElement.addContent(new CDATA(query));
      rootElement.addContent(queryElement);

      // create a result attribute for the queryID
      Attribute resultsIDAttribute = new Attribute(
        TagNames.Attributes.NAME, queryID);

      if (result != null) {
    // produce a JDOM element from the results object
    Element resultsElement = jstrat.produceResults(result);
View Full Code Here

      Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);

      // create a JDOM element for the results
      Element resultElement = new Element(TagNames.Elements.QUERY_RESULTS);
      // set the queryIDAttr on the exception element
      resultElement.setAttribute(new Attribute(TagNames.Attributes.NAME,
        queryID));
      // set the querySQLAttr on the exception element
      resultElement.setAttribute(new Attribute(TagNames.Attributes.VALUE,
        sql));

      // ---------------------
      // Actual Exception
      // ---------------------
View Full Code Here

        throw new EnterpriseConfigurationObjectException(errMsg);
      }

      // determine if we should initialize this AppConfig object using threads or not.
      // default is 'true' (we should use threads).
      Attribute aInitializeUsingThreads =
        eConfig.getAttribute("initializeUsingThreads");
      if (aInitializeUsingThreads != null) {
        String initUsingThreads = aInitializeUsingThreads.getValue();
        logger.debug("initUsingThreads String value: '" + initUsingThreads +
                     "'");
        if (initUsingThreads.equalsIgnoreCase("true") == false &&
            initUsingThreads.equalsIgnoreCase("false") == false) {
          initUsingThreads = "true";
View Full Code Here

    Element eLayouts = eField.getChild("Layouts");
    if (eLayouts != null) {
      java.util.List lLayouts = eLayouts.getChildren("Layout");
      for (int i=0; i<lLayouts.size(); i++) {
        Element eLayout = (Element)lLayouts.get(i);
        Attribute aName = eLayout.getAttribute("name");
        if (aName != null) {
          String layoutName = aName.getValue();
          logger.debug("Layout [" + i + "] name is: " + layoutName);
          if (layoutName.equalsIgnoreCase(name)) {
            return eLayout;
          }
        }
View Full Code Here

    setTranslationType(transType);

    addProperty("xmlDocumentValidation", configElement.getAttribute("xmlDocumentValidation").getValue());

    boolean deferInitialization = false;
    Attribute aDefer = configElement.getAttribute("deferInitialization");
    if (aDefer != null) {
      deferInitialization = new Boolean(aDefer.getValue()).booleanValue();
    }

    Document enterpriseObjectsDoc = null;
    String messageObjectClassName = configElement.getChild("ObjectClass").getText();
    String messageObjectName = messageObjectClassName.substring(messageObjectClassName.lastIndexOf('.') + 1);
    String eoDocUri = null;

    java.util.List props = configElement.getChildren();
    boolean keepTrying = true;
    while(keepTrying) {
    int propsSize = props.size();
    if (propsSize == 0) {
      keepTrying = false;
    }
    for (int i=0; i<propsSize; i++) {
      Element aProp = (Element)props.get(0);
      props.remove(0);
      if (aProp.getName().equals("Authentication")) {
        // UserId, Signature
        java.util.List auths = aProp.getChildren();
        for (int j=0; j<auths.size(); j++) {
          Element anAuthChild = (Element)auths.get(j);
          String key = anAuthChild.getName();
          String value = anAuthChild.getText();
          logger.debug("Adding " + key + " - " + value);
          addProperty(key, value);
        }
      }
      else if (aProp.getName().equals("PrimedXmlDocuments")) {
        java.util.List docs = aProp.getChildren();
        for (int k=0; k<docs.size(); k++) {
          Element aDoc = (Element)docs.get(k);
          String key, value;
          key = aDoc.getAttribute("type").getValue() + "-" + aDoc.getName();
          value = aDoc.getText();
          logger.debug("Adding " + key + " - " + value);
          addProperty(key, value);
        }
      }
      // NEW ENTERPRISEFIELDS CONFIGURATION START - 8/8
      else if (aProp.getName().equals("EnterpriseObjectDocument")) {
        eoDocUri = aProp.getAttribute("docUri").getValue();

        // new 7/30/2002, changed config document to allow multiple EnterpriseObject.xml
        // documents.  This way, we can break them apart and make each "chunk" smaller
        // this should decrease the time necessary to build an object and make AppConfig
        // initilialization quicker.
        if (enterpriseObjectsDoc == null) {
          if (eoDocUri != null) {
            try {

              //TODO: check for deferInitialization flag.  If True, don't parse the document yet.
              if (deferInitialization == false) {
                logger.debug("EF initialization is NOT deferred, parsing EO docs...");
                XmlDocumentReader xmlReader = new XmlDocumentReader();
                enterpriseObjectsDoc =
                  xmlReader.initializeDocument(eoDocUri,getValidation());
                logger.debug("DONE parsing EO docs.");
              }
              else {
                logger.debug("EnterpriseFields initialization has been deferred (not parsing EO doc).");
              }
               
            }
            catch (XmlDocumentReaderException e) {
              logger.fatal(e.getMessage(), e);
              String msg = "Exception occurred initializing EnterpriseFields object.  Exception: " + e.getMessage();
              logger.fatal(msg);
              throw new EnterpriseConfigurationObjectException(msg, e);
            }
          }
        }
        if (getEnterpriseFields() == null) {
          EnterpriseFields fields = new EnterpriseFields();
          fields.setEnterpriseObjectsUri(eoDocUri);
          fields.setIgnoreMissingFields(new Boolean(aProp.getAttribute("ignoreMissingFields").getValue()).booleanValue());
          fields.setIgnoreValidation(new Boolean(aProp.getAttribute("ignoreValidation").getValue()).booleanValue());
          logger.debug("[MessageObjectConfig] ignoreValidation is " + fields.ignoreValidation());
          fields.setTranslationType(getTranslationType());
          fields.setAppName(getAppName());
//          ObjectDefinitions.APP_NAME = getAppName();
          try {

            //TODO:  check for deferInitialization flag.  If true, don't do this yet.
            if (deferInitialization == false) {
              logger.debug("EnterpriseFields initialization is NOT deferred, initializing EF...");
              fields.init(enterpriseObjectsDoc);
              logger.debug("DONE with EnterpriseFields initialization.");
            }
            else {
              logger.debug("EnterpriseFields initialization has been deferred (not initializing EnterpriseFields).");
            }
           
          }
          catch (EnterpriseFieldException e) {
            String msg = "Exception occurred initializing EnterpriseFields object.  Exception: " + e.getMessage();
            logger.fatal(msg);
            throw new EnterpriseConfigurationObjectException(msg, e);
          }
          setEnterpriseFields(fields);
        }
      }
      // NEW ENTERPRISEFIELDS CONFIGURATION END - 8/8

      // NEW LAYOUT MANAGER CONFIGURATION START - 8/8
      else if (aProp.getName().equals("LayoutManager")) {
        // Build all of the layout manager objects...
        logger.debug("MessageObjectName is " + messageObjectName);

        //TODO:  may have to check deferInitialization flag here also...
//        if (enterpriseObjectsDoc == null && deferInitialization == false) {
        if (eoDocUri == null) {
          String msg = "[MessageObjectConfig] Cannot initialize LayoutManagers until the EnterpriseObjectDocument has been initialized, putting it back on the list";
          logger.warn(msg);
          props.add(aProp);
          continue;
        }
       
        logger.debug("Initializing layout managers...");
        java.util.List lInputLayouts = aProp.getChildren("InputLayout");
        boolean hasXmlLayoutManager = false;
        for (int im=0; im<lInputLayouts.size(); im++) {
          Element eInLayout = (Element)lInputLayouts.get(im);
          String inputLayoutType = eInLayout.getAttribute("type").getValue();
          String inputLayoutName = "";
          if (inputLayoutType.equals("xml")) {
            hasXmlLayoutManager = true;
            Attribute aInLayoutName = eInLayout.getAttribute("name");
            if (aInLayoutName != null) {
              inputLayoutName = aInLayoutName.getValue();
            }
            else {
              String className = getClass().getName();
              inputLayoutName = className.substring(className.lastIndexOf('.') + 1)// Our based element in the XML passed in
            }
          }
          else {
            Attribute aInLayoutName = eInLayout.getAttribute("name");
            if (aInLayoutName != null) {
              inputLayoutName = aInLayoutName.getValue();
            }
            else {
              String msg = "[MessageObjectConfig] Non-XML input layouts must have a name associated with them.";
              logger.fatal(msg);
              throw new EnterpriseConfigurationObjectException(msg);
            }
          }
          String inLayoutClass = eInLayout.getChild("ObjectClass").getText();
          try {
            logger.debug("Instantiating input layout manager: " + inLayoutClass + " for " + inputLayoutName);
            java.lang.Class inLayoutObj = java.lang.Class.forName(inLayoutClass);

            EnterpriseLayoutManager ainElm = (EnterpriseLayoutManager)inLayoutObj.newInstance();

            //TODO: check deferInitialization flag.
//            ainElm.init(messageObjectName, inputLayoutName, enterpriseObjectsDoc);
            if (deferInitialization == false) {
              logger.debug("Layout manager initialization is NOT deferred, initializing input layout manager...");
              ainElm.init(inputLayoutName, enterpriseObjectsDoc);
              logger.debug("DONE initializing input layout manager...");
            }
            else {
              logger.debug("Layout manager initialization has been deferred (input)");
              ainElm.setLayoutManagerName(inputLayoutName);
              ainElm.setEnterpriseObjectsUri(eoDocUri);
            }
           
            addInputLayoutManager(inputLayoutType, ainElm);
            // Set the default input layout manager to the first one in the list.
            if (im == 0) {
              setInputLayoutManager(ainElm);
            }
          }
          catch (Exception e) {
            String msg = "Error initializing Input Layout Manager.  Exception: " + e.getMessage();
            logger.fatal(msg, e);
            throw new EnterpriseConfigurationObjectException(msg, e);
          }
        }
        if (hasXmlLayoutManager == false) {
          // throw an exception
          String msg = "[MessageObjectConfig] Missing XML Input Layout manager.";
          logger.fatal(msg);
          throw new EnterpriseConfigurationObjectException(msg);
        }

        logger.debug("MessageObjectName is " + messageObjectName);
        java.util.List lOutputLayouts = aProp.getChildren("OutputLayout");
        hasXmlLayoutManager = false;
        for (int om=0; om<lOutputLayouts.size(); om++) {
          Element eOutLayout = (Element)lOutputLayouts.get(om);
          String outputLayoutType = eOutLayout.getAttribute("type").getValue();
          String outputLayoutName = "";
          if (outputLayoutType.equals("xml")) {
            hasXmlLayoutManager = true;
            Attribute aOutLayoutName = eOutLayout.getAttribute("name");
            if (aOutLayoutName != null) {
              outputLayoutName = aOutLayoutName.getValue();
            }
            else {
              String className = getClass().getName();
              outputLayoutName =className.substring(className.lastIndexOf('.') + 1)// Our based element in the XML passed in
            }
          }
          else {
            Attribute aOutLayoutName = eOutLayout.getAttribute("name");
            if (aOutLayoutName != null) {
              outputLayoutName = aOutLayoutName.getValue();
            }
            else {
              String msg = "[MessageObjectConfig] Non-XML output layouts must have a name associated with them.";
              logger.fatal(msg);
              throw new EnterpriseConfigurationObjectException(msg);
View Full Code Here

   */
  public void init(Element eCommand) throws EnterpriseConfigurationObjectException {
    setName(eCommand.getChild("CommandName").getText());
    setClassName(eCommand.getChild("CommandClass").getText());
    setType(eCommand.getAttribute("type").getValue());
    Attribute aDefault = eCommand.getAttribute("isDefault");
    if (aDefault != null) {
      setDefault(new Boolean(aDefault.getValue()).booleanValue());
    }
    else {
      setDefault(false);
    }

    Attribute aAbsolute = eCommand.getAttribute("isAbsolute");
    if (aAbsolute != null) {
      setAbsolute(new Boolean(aAbsolute.getValue()).booleanValue());
    }
    else {
      setAbsolute(false);
    }

    Attribute aInboundValidation = eCommand.getAttribute("inboundXmlValidation");
    if (aInboundValidation != null) {
      setInboundXmlValidation(new Boolean(aInboundValidation.getValue()).booleanValue());
    }
    else {
      // Use default values...
      aInboundValidation = getDefaultParms().getAttribute("inboundXmlValidation");
      if (aInboundValidation != null) {
        setInboundXmlValidation(new Boolean(aInboundValidation.getValue()).booleanValue());
      }
      else {
        setInboundXmlValidation(false);
      }
    }

    Attribute aOutboundValidation = eCommand.getAttribute("outboundXmlValidation");
    if (aOutboundValidation != null) {
      setOutboundXmlValidation(new Boolean(aOutboundValidation.getValue()).booleanValue());
    }
    else {
      // Use default values...
      aOutboundValidation = getDefaultParms().getAttribute("outboundXmlValidation");
      if (aOutboundValidation != null) {
        setOutboundXmlValidation(new Boolean(aOutboundValidation.getValue()).booleanValue());
      }
      else {
        setOutboundXmlValidation(false);
      }
    }

    Attribute aWriteToFile = eCommand.getAttribute("writeToFile");
    if (aWriteToFile != null) {
      setWriteToFile(new Boolean(aWriteToFile.getValue()).booleanValue());
    }
    else {
      // Use default values...
      aWriteToFile = getDefaultParms().getAttribute("writeToFile");
      if (aWriteToFile != null) {
        setWriteToFile(new Boolean(aWriteToFile.getValue()).booleanValue());
      }
      else {
        setWriteToFile(false);
      }
    }

    Attribute aMsgDumpDir = eCommand.getAttribute("messageDumpDirectory");
    if (aMsgDumpDir != null) {
      setMessageDumpDirectory(aMsgDumpDir.getValue());
    }
    else {
      // Use default values...
      aMsgDumpDir = getDefaultParms().getAttribute("messageDumpDirectory");
      if (aMsgDumpDir != null) {
        setMessageDumpDirectory(aMsgDumpDir.getValue());
      }
    }

    logger.debug("Element returned: ");
    logger.debug("  - " + eCommand.getName());
View Full Code Here

TOP

Related Classes of org.jdom.Attribute

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.