/** startElement handler */
 public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
     throws SAXException {
   //
   //   if sourceElement
   //
   if (qName.equals("source")) {
     String sourceFile = atts.getValue("file");
     long sourceLastModified = Long.parseLong(atts.getValue("lastModified"), 16);
     sources.addElement(new SourceHistory(sourceFile, sourceLastModified));
   } else {
     //
     //   if <target> element,
     //      grab file name and lastModified values
     //      TargetHistory object will be created in endElement
     //
     if (qName.equals("target")) {
       sources.setSize(0);
       output = atts.getValue("file");
       outputLastModified = Long.parseLong(atts.getValue("lastModified"), 16);
     } else {
       //
       //   if <processor> element,
       //       grab signature attribute
       //
       if (qName.equals("processor")) {
         config = atts.getValue("signature");
       }
     }
   }
 }
 @Override
 public void startElement(
     final String uri, final String localName, final String qName, final Attributes attributes)
     throws SAXException {
   if ("testResults".equals(localName)) {
     // Check the version and output a warning if it differs
     final String version = attributes.getValue("version");
     if (version == null) {
       log.warn("No version specified in JTL file");
     } else {
       if (!version.equals(JTL_VERSION)) {
         log.warn("Parsing unknown JTL version: " + version);
       }
     }
   } else if ("sample".equals(localName) || "httpSample".equals(localName)) {
     // Get the label
     String label = attributes.getValue("lb");
     if ((label == null) || (label.length() == 0)) {
       label = "null";
     }
     SamplerImpl sampler = (SamplerImpl) samplerMap.get(label);
     if (sampler == null) {
       sampler = new SamplerImpl(label);
       samplerMap.put(label, sampler);
     }
     final long sampleTime = getLongAttribute(attributes, "t");
     final long startTime = getLongAttribute(attributes, "ts");
     final boolean pass = getBooleanAttribute(attributes, "s");
     sampler.addSample(startTime, sampleTime, pass);
     totalSampler.addSample(startTime, sampleTime, pass);
   }
 }
    public void init(String name, Attributes atts) {

      logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); // $NON-NLS-1$
      super.init(name, atts);
      String icon_resource_val = atts.getValue(RESOURCE);
      if (icon_resource_val == null) {
        _isParsedDataValid = false;
        logger.log(
            LogService.LOG_ERROR,
            NLS.bind(
                MetaTypeMsg.MISSING_ATTRIBUTE,
                new Object[] {
                  RESOURCE,
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
        return;
      }

      String icon_size_val = atts.getValue(SIZE);
      if (icon_size_val == null) {
        // Not a problem, because SIZE is an optional attribute.
        icon_size_val = "0"; // $NON-NLS-1$
      } else if (icon_size_val.equalsIgnoreCase("")) { // $NON-NLS-1$
        icon_size_val = "0"; // $NON-NLS-1$
      }

      _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle);
    }
Ejemplo n.º 4
0
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      if (qName.equals("rdf:RDF")) {
        isRoot = false;
      } else if (qName.equals("rss") && attributes.getValue(0).equals("2.0")) {
        isRoot = false;
      } else if (isRoot) {
        throw new SAXException("It is a form of the RSS that is not supported.");
      }

      if (uri.startsWith(RDF_CALENDAR_NAMESPACE)) {
        qName = localName;
        if (qName.equals("Vcalendar")) {
          // xml.write("BEGIN:VCALENDAR\n");
        } else if (qName.equals("Vevent")) {
          xml.write("BEGIN:VEVENT\n");
          rrule = new StringBuffer();
          qNameList.clear();
        } else if (qName.equals("url")) {
          urlAttr = attributes.getValue(0);
        } else if (qName.equals("dtstart")) {
          parentTag = qName;
        } else if (qName.equals("dtend")) {
          parentTag = qName;
        } else if (qName.equals("dtstamp")) {
          parentTag = qName;
        }
      }
      // tagStack.add(qName);
      buf.reset();
      qNameList.add(qName);
      isMixed = false;
    }
Ejemplo n.º 5
0
 private Charger createCharger(Attributes atts) {
   Id<Charger> id = Id.create(atts.getValue("id"), Charger.class);
   Link link = links.get(Id.createLinkId(atts.getValue("link")));
   double power_kW = ReaderUtils.getDouble(atts, "power", DEFAULT_CHARGER_POWER_kW);
   int plugs = ReaderUtils.getInt(atts, "capacity", DEFAULT_CHARGER_CAPACITY);
   return new ChargerImpl(id, power_kW * EvUnitConversions.W_PER_kW, plugs, link);
 }
Ejemplo n.º 6
0
    /* (non-Javadoc)
     * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
     */
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      super.startElement(uri, localName, qName, attributes);
      for (DefaultHandler delegate : delegates) {
        delegate.startElement(uri, localName, qName, attributes);
      }
      boolean policy = false;
      if (localName != null && localName.equals(POLICY)) {
        policy = true;
      }
      if (qName != null && qName.endsWith(COLON_POLICY)) {
        policy = true;
      }
      if (!policy) {
        return;
      } else {
        hasPolicy = true;
      }
      int count = attributes.getLength();
      for (int i = 0; i < count; i++) {
        String value = attributes.getValue(i);
        String attrLocalName = attributes.getLocalName(i);
        String attrQName = attributes.getQName(i);

        if ((attrLocalName != null && attrLocalName.equals(ID))
            || (attrLocalName != null && attrQName.endsWith(COLON_ID))) {
          policies.add(attributes.getValue(i));
        }
      }
    }
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    isReachablesElement = "Reachables".equals(qName);

    if (isReachablesElement || !isLocalViewsAttributeName) {

      isLocalViewsAttributeName = "Views".equals(attributes.getValue("Name"));
    }

    if (isLocalViewsAttributeName) {

      isSetElement = "Set".equals(qName);

      isEntryElement = "Entry".equals(qName);

      String valueAttribute;

      if (isSetElement) {

        valueAttribute = attributes.getValue("Agent");

        sets.add(new Set(valueAttribute));
      }

      if (isEntryElement) {

        valueAttribute = attributes.getValue("Data");

        entres.add(new Entry(valueAttribute));
      }
    }
  }
 protected void startElement(DAVElement parent, DAVElement element, Attributes attrs)
     throws SVNException {
   if (element == FILE_REVISION) {
     myPath = attrs.getValue("path");
     myRevision = Long.parseLong(attrs.getValue("rev"));
   } else if (element == REVISION_PROPERTY
       || element == SET_PROPERTY
       || element == DELETE_PROPERTY) {
     myPropertyName = attrs.getValue("name");
     myPropertyEncoding = attrs.getValue("encoding");
   }
   if (element == TX_DELTA) {
     // handle file revision with props.
     if (myPath != null && myFileRevisionsHandler != null) {
       if (myProperties == null) {
         myProperties = Collections.EMPTY_MAP;
       }
       if (myPropertiesDelta == null) {
         myPropertiesDelta = Collections.EMPTY_MAP;
       }
       SVNFileRevision revision =
           new SVNFileRevision(myPath, myRevision, myProperties, myPropertiesDelta);
       myFileRevisionsHandler.openRevision(revision);
       myProperties = null;
       myPropertiesDelta = null;
       myPath = null;
       myFileRevisionsHandler.applyTextDelta(myPath, null);
     }
     setDeltaProcessing(true);
   }
 }
Ejemplo n.º 9
0
  private String process_uniqueCounter(String s, Attributes attributes) {
    String s1 = null;
    String s2 = SunOneMonitor.getAttrForUniqueCounter(s);
    int i = attributes.getLength();
    int j = 0;
    do {
      if (j >= i) {
        break;
      }
      String s3 = attributes.getLocalName(j);
      if (s3.equals(s2)) {
        s1 = s + "@" + s2 + "-" + attributes.getValue(j);
        break;
      }
      j++;
    } while (true);
    if (s1 == null) {
      s1 = s;
    }
    writer.startElement("object name=\"" + s1 + "\"");
    for (int k = 0; k < i; k++) {
      String s4 = attributes.getLocalName(k);
      String s5 = attributes.getValue(k);
      String s6 = s4 + "+" + s5;
      if (!s4.equals(s2)) {
        writer.emptyElement("counter name=\"" + s4 + "\" id=\"" + s6 + "\"");
      }
    }

    return s1;
  }
Ejemplo n.º 10
0
 public void setFromAttributes(Attributes attributes) {
   String name = attributes.getValue("name");
   String value = attributes.getValue("value");
   if ("effect".equals(name)) {
     this.effect = value;
   }
 }
Ejemplo n.º 11
0
  /**
   * Create or retrieve an instance of <code>IconBean</code> and push it on to the object statck.
   *
   * @param namespace the namespace URI of the matching element, or an empty string if the parser is
   *     not namespace aware or the element has no namespace
   * @param name the local name if the parser is namespace aware, or just the element name otherwise
   * @param attributes The attribute list of this element
   * @exception IllegalStateException if the parent stack element is not of type FeatureBean
   */
  public void begin(String namespace, String name, Attributes attributes) throws Exception {

    FeatureBean fb = null;
    try {
      fb = (FeatureBean) digester.peek();
    } catch (Exception e) {
      throw new IllegalStateException("No parent FeatureBean on object stack");
    }
    String lang = attributes.getValue("lang");
    if (lang == null) {
      lang = attributes.getValue("xml:lang"); // If digester not ns-aware
    }
    if (lang == null) {
      lang = ""; // Avoid NPE errors on sorted map comparisons
    }
    IconBean ib = fb.getIcon(lang);
    if (ib == null) {
      if (digester.getLogger().isDebugEnabled()) {
        digester.getLogger().debug("[IconRule]{" + digester.getMatch() + "} New (" + lang + ")");
      }
      Class clazz = digester.getClassLoader().loadClass(CLASS_NAME);
      ib = (IconBean) clazz.newInstance();
      ib.setLang(lang);
      fb.addIcon(ib);
    } else {
      if (digester.getLogger().isDebugEnabled()) {
        digester.getLogger().debug("[IconRule]{" + digester.getMatch() + "} Old (" + lang + ")");
      }
    }
    digester.push(ib);
  }
 @Override
 public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
     throws SAXException {
   if ("message".equals(qName)) {
     entry = new EntryImpl();
     for (int i = 0; i < atts.getLength(); i++) {
       if ("time".equals(atts.getQName(i))) {
         try {
           entry.setTime(EmpathyParser.TIME_FORMAT.parse(atts.getValue(i)));
         } catch (ParseException ex) {
           LOG.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
         }
       }
       if ("name".equals(atts.getQName(i))) {
         entry.setName(atts.getValue(i));
       }
       if ("type".equals(atts.getQName(i))) {
         entry.setType(atts.getValue(i));
       }
       if ("id".equals(atts.getQName(i))) {
         entry.setId(atts.getValue(i));
       }
     }
   }
 }
    public void startElement(
        String uri, String localName, String qName, org.xml.sax.Attributes atts)
        throws SAXException {
      if (DICTIONARY_ELEMENT.equals(localName)) {

        mAttributes = new Attributes();

        for (int i = 0; i < atts.getLength(); i++) {
          mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
        }
        /* get the attribute here ... */
        if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) {
          mIsCaseSensitiveDictionary =
              Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE));
        }
        mAttributes = null;
      } else if (ENTRY_ELEMENT.equals(localName)) {

        mAttributes = new Attributes();

        for (int i = 0; i < atts.getLength(); i++) {
          mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
        }
      } else if (TOKEN_ELEMENT.equals(localName)) {
        mIsInsideTokenElement = true;
      }
    }
Ejemplo n.º 14
0
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {
    ModelReader8Handler.ElementHandler current =
        (myHandlersStack.empty()
            ? (ModelReader8Handler.ElementHandler) null
            : myHandlersStack.peek());
    if (current == null) {
      // root
      current = modelhandler;
    } else {
      current = current.createChild(myValues.peek(), qName, attributes);
    }

    // check required
    for (String attr : current.requiredAttributes()) {
      if (attributes.getValue(attr) == null) {
        throw new SAXParseException("attribute " + attr + " is absent", null);
      }
    }

    Object result = current.createObject(attributes);
    if (myHandlersStack.empty()) {
      myResult = (ModelLoadResult) result;
    }

    // handle attributes
    for (int i = 0; i < attributes.getLength(); i++) {
      String name = attributes.getQName(i);
      String value = attributes.getValue(i);
      current.handleAttribute(result, name, value);
    }
    myHandlersStack.push(current);
    myValues.push(result);
  }
  /** Retrieve and remove the namespaces declarations from the list of attributes. */
  private Attributes extractNamespaces(Attributes attrs) throws SAXException {
    AttributesImpl attrsOnly;
    String rawName;
    int i;
    int indexColon;
    String prefix;
    int length;

    if (attrs == null) {
      return null;
    }
    length = attrs.getLength();
    attrsOnly = new AttributesImpl(attrs);

    for (i = length - 1; i >= 0; --i) {
      rawName = attrsOnly.getQName(i);

      // We have to exclude the namespaces declarations from the attributes
      // Append only when the feature http://xml.org/sax/features/namespace-prefixes"
      // is TRUE
      if (rawName.startsWith("xmlns")) {
        if (rawName.length() == 5) {
          startPrefixMapping("", attrs.getValue(i));
          attrsOnly.removeAttribute(i);
        } else if (rawName.charAt(5) == ':') {
          startPrefixMapping(rawName.substring(6), attrs.getValue(i));
          attrsOnly.removeAttribute(i);
        }
      }
    }
    return attrsOnly;
  }
Ejemplo n.º 16
0
  @Override
  void startElement(String qName, Attributes attributes) throws SAXException {

    elementStack.push(qName);

    switch (QNAME.valueOf(qName)) {
      case candles:
        CandleGraph candleGraph = new CandleGraph();
        candleGraph.setPeriod(Integer.valueOf(attributes.getValue("period")));
        candleGraph.setStatus(CandleStatus.getFromValue(attributes.getValue("status")));
        candleGraph.setBoard(attributes.getValue("board"));
        candleGraph.setSeccode(attributes.getValue("seccode"));
        objectStack.push(candleGraph);
        break;

      case candle:
        Candle candle = new Candle();
        candle.setDate(Utils.parseDate(attributes.getValue("date")));
        candle.setOpen(Double.valueOf(attributes.getValue("open")));
        candle.setHigh(Double.valueOf(attributes.getValue("high")));
        candle.setLow(Double.valueOf(attributes.getValue("low")));
        candle.setClose(Double.valueOf(attributes.getValue("close")));
        candle.setVolume(Integer.valueOf(attributes.getValue("volume")));
        String oi = attributes.getValue("oi");
        if (oi != null) {
          candle.setOi(Integer.valueOf(oi));
        }
        objectStack.peek().getCandles().add(candle);
        break;
      default:
        break;
    }
  }
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {

      if (qName.equals(XML_NODE_SETTING)) {

        final String key = attributes.getValue(XML_ATTRIBUTE_ID);
        final String value = attributes.getValue(XML_ATTRIBUTE_VALUE);
        fSettings.put(key, value);

      } else if (qName.equals(XML_NODE_PROFILE)) {

        fName = attributes.getValue(XML_ATTRIBUTE_NAME);
        fKind = attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);

        fSettings = new HashMap<String, String>(200);

      } else if (qName.equals(XML_NODE_ROOT)) {

        fProfiles = new ArrayList<Profile>();
        try {
          fVersion = Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
        } catch (NumberFormatException ex) {
          throw new SAXException(ex);
        }
      }
    }
Ejemplo n.º 18
0
 private void startLeg(final Attributes atts) {
   this.currleg =
       this.currplan.createAndAddLeg(atts.getValue("mode").toLowerCase(Locale.ROOT).intern());
   this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time")));
   this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time")));
   this.currleg.setArrivalTime(Time.parseTime(atts.getValue("arr_time")));
 }
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attributes)
     throws SAXException {
   super.startElement(uri, localName, qName, attributes);
   if (localName.equals("repo")) {
     String pk = attributes.getValue("", "pubkey");
     if (pk != null) pubkey = pk;
   } else if (localName.equals("application") && curapp == null) {
     curapp = new DB.App();
     curapp.detail_Populated = true;
     Bundle progressData = createProgressData(repo.address);
     progressCounter++;
     progressListener.onProgress(
         new ProgressListener.Event(
             RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML,
             progressCounter,
             totalAppCount,
             progressData));
   } else if (localName.equals("package") && curapp != null && curapk == null) {
     curapk = new DB.Apk();
     curapk.id = curapp.id;
     curapk.repo = repo.id;
     hashType = null;
   } else if (localName.equals("hash") && curapk != null) {
     hashType = attributes.getValue("", "type");
   }
   curchars.setLength(0);
 }
Ejemplo n.º 20
0
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
        throws SAXException {
      System.out.println("::XMLParser::startElement::" + qName + ":" + atts);
      if (qName.equalsIgnoreCase(TAG_DOC)) {

        mDoc = true;
        mWikiDoc = new WikipediaDocument();

        String id = atts.getValue("id");
        if (id != null && id.trim().length() > 0) {
          mWikiDoc.setId(Integer.parseInt(id));
        }
        String url = atts.getValue("url");
        if (url != null && url.trim().length() > 0) {
          mWikiDoc.setWikilink(url);
        }
        String title = atts.getValue("title");
        if (title != null && title.trim().length() > 0) {
          mWikiDoc.setTitle(title);
        }
        String timestamp = atts.getValue("timestamp");
        if (timestamp != null && timestamp.trim().length() > 0) {
          mWikiDoc.setTimestamp(timestamp);
        }
      }
    }
Ejemplo n.º 21
0
 public Object createObject(Attributes atts) {
   return new JROrigin(
       atts.getValue(JRXmlConstants.ATTRIBUTE_report),
       atts.getValue(JRXmlConstants.ATTRIBUTE_group),
       ((Byte) JRXmlConstants.getBandTypeMap().get(atts.getValue(JRXmlConstants.ATTRIBUTE_band)))
           .byteValue());
 }
Ejemplo n.º 22
0
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String packageName = attrs.getValue("http://www.jboss.org/drools", "packageName");

    RuleFlowProcess process = new RuleFlowProcess();
    process.setAutoComplete(true);
    process.setId(id);
    if (name == null) {
      name = id;
    }
    process.setName(name);
    process.setType("RuleFlow");
    if (packageName == null) {
      packageName = "org.drools.bpmn2";
    }
    process.setPackageName(packageName);

    ((ProcessBuildData) parser.getData()).setProcess(process);
    return process;
  }
Ejemplo n.º 23
0
  @SuppressWarnings("unchecked")
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String type = attrs.getValue("structureRef");
    if (type == null || type.trim().length() == 0) {
      type = "java.lang.Object";
    }

    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    Map<String, ItemDefinition> itemDefinitions =
        (Map<String, ItemDefinition>) buildData.getMetaData("ItemDefinitions");
    if (itemDefinitions == null) {
      itemDefinitions = new HashMap<String, ItemDefinition>();
      buildData.setMetaData("ItemDefinitions", itemDefinitions);
    }
    ItemDefinition itemDefinition = new ItemDefinition(id);
    itemDefinition.setStructureRef(type);
    itemDefinitions.put(id, itemDefinition);
    return itemDefinition;
  }
Ejemplo n.º 24
0
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser xmlPackageReader)
      throws SAXException {
    xmlPackageReader.startElementBuilder(localName, attrs);

    WorkflowProcessImpl process = (WorkflowProcessImpl) xmlPackageReader.getParent();

    ActionNode actionNode = new ActionNode();

    final String name = attrs.getValue("name");
    emptyAttributeCheck(localName, "name", name, xmlPackageReader);
    actionNode.setName(name);

    final String id = attrs.getValue("id");
    emptyAttributeCheck(localName, "id", name, xmlPackageReader);
    actionNode.setId(new Long(id));

    process.addNode(actionNode);
    ((ProcessBuildData) xmlPackageReader.getData()).addNode(actionNode);

    return actionNode;
  }
Ejemplo n.º 25
0
  public void startElement(String namespaceURI, String sName, String qName, Attributes attrs)
      throws SAXException {

    echoText();

    String eName = sName; // element name
    if ("".equals(eName)) {
      eName = qName; // not namespace-aware
    }

    if ("HTTPSamplerProxy".equals(eName)) {
      startBuffer();
    }

    emit("<" + eName);
    if (attrs != null) {
      for (int i = 0; i < attrs.getLength(); i++) {
        String aName = attrs.getLocalName(i); // Attr name
        if ("".equals(aName)) aName = attrs.getQName(i);

        emit(" ");
        if ("HTTPSamplerProxy".equals(eName) && "testname".equals(aName)) {
          this.testName = attrs.getValue(i);
        }
        emit(aName + "=\"" + attrs.getValue(i) + "\"");
      }
    }

    emit(">");
  }
Ejemplo n.º 26
0
 @Override
 public void startElement(
     final String uri, final String localName, final String qName, final Attributes attributes)
     throws SAXException {
   if (qName.equals("database")) {
     stack.push(new Object());
     if (StringUtils.isNotBlank(attributes.getValue("package"))) {
       destinationPackage = new JavaPackage(attributes.getValue("package"));
     }
   } else if (qName.equals("option")) {
     stack.push(new Option(attributes.getValue("key"), attributes.getValue("value")));
   } else if (qName.equals("table")) {
     stack.push(getTable(attributes));
   } else if (qName.equals("column")) {
     stack.push(getColumn(attributes));
   } else if (qName.equals("foreign-key")) {
     stack.push(getForeignKey(attributes));
   } else if (qName.equals("reference")) {
     stack.push(getReference(attributes));
   } else if (qName.equals("unique")) {
     stack.push(getIndex(attributes, IndexType.UNIQUE));
   } else if (qName.equals("index")) {
     stack.push(getIndex(attributes, IndexType.INDEX));
   } else if (qName.equals("unique-column") || qName.equals("index-column")) {
     stack.push(getIndexColumn(attributes));
   }
 }
Ejemplo n.º 27
0
  /** Instantiates an layout of the given class and sets its name. */
  public void begin(InterpretationContext ec, String localName, Attributes attributes) {
    // Let us forget about previous errors (in this object)
    inError = false;
    String errorMsg;
    String pattern = attributes.getValue(Action.PATTERN_ATTRIBUTE);
    String actionClass = attributes.getValue(Action.ACTION_CLASS_ATTRIBUTE);

    if (OptionHelper.isEmpty(pattern)) {
      inError = true;
      errorMsg = "No 'pattern' attribute in <newRule>";
      addError(errorMsg);
      return;
    }

    if (OptionHelper.isEmpty(actionClass)) {
      inError = true;
      errorMsg = "No 'actionClass' attribute in <newRule>";
      addError(errorMsg);
      return;
    }

    try {
      addInfo("About to add new Joran parsing rule [" + pattern + "," + actionClass + "].");
      ec.getJoranInterpreter().getRuleStore().addRule(new Pattern(pattern), actionClass);
    } catch (Exception oops) {
      inError = true;
      errorMsg = "Could not add new Joran parsing rule [" + pattern + "," + actionClass + "]";
      addError(errorMsg);
    }
  }
  private boolean checkAttributes(Attributes attributes) {
    String fileAttribute = attributes.getValue(FILE_ATTR);
    String urlAttribute = attributes.getValue(URL_ATTR);
    String resourceAttribute = attributes.getValue(RESOURCE_ATTR);

    int count = 0;

    if (!OptionHelper.isEmpty(fileAttribute)) {
      count++;
    }
    if (!OptionHelper.isEmpty(urlAttribute)) {
      count++;
    }
    if (!OptionHelper.isEmpty(resourceAttribute)) {
      count++;
    }

    if (count == 0) {
      addError("One of \"path\", \"resource\" or \"url\" attributes must be set.");
      return false;
    } else if (count > 1) {
      addError("Only one of \"file\", \"url\" or \"resource\" attributes should be set.");
      return false;
    } else if (count == 1) {
      return true;
    }
    throw new IllegalStateException("Count value [" + count + "] is not expected");
  }
Ejemplo n.º 29
0
  @SuppressWarnings("unchecked")
  public Object start(
      final String uri,
      final String localName,
      final Attributes attrs,
      final ExtensibleXmlParser parser)
      throws SAXException {
    parser.startElementBuilder(localName, attrs);

    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String implRef = attrs.getValue("implementationRef");

    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    List<Interface> interfaces = (List<Interface>) buildData.getMetaData("Interfaces");
    if (interfaces == null) {
      interfaces = new ArrayList<Interface>();
      buildData.setMetaData("Interfaces", interfaces);
    }
    Interface i = new Interface(id, name);
    if (implRef != null) {
      i.setImplementationRef(implRef);
    }
    interfaces.add(i);
    return i;
  }
Ejemplo n.º 30
0
  /** Called when tag starts ( ex:- <name>AndroidPeople</name> -- <name> ) */
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    currentElement = true;

    if (localName.equals("members")) {
      memberList = new ArrayList<Member>();
    } else if (localName.equals("member")) {
      try {
        /** Get attribute values */
        Member member = new Member();
        member.setId(attributes.getValue("id"));
        member.setAddress(attributes.getValue("address"));
        member.setCity(attributes.getValue("city"));
        member.setEmail(attributes.getValue("email"));
        member.setMobile(attributes.getValue("mobile"));
        member.setName(attributes.getValue("name"));
        member.setPhone(attributes.getValue("phone"));
        member.setPostcode(attributes.getValue("postcode"));
        member.setTrial(attributes.getValue("trial").equalsIgnoreCase("YES"));
        member.setImagePath(attributes.getValue("photo"));
        memberList.add(member);
      } catch (Exception e) {

      }
    }
  }