コード例 #1
0
  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    curElem = false;
    curValue = curValue.trim();

    // check for a known tag
    if (qName.equals("name")) {
      curMission.setName(curValue);
    } else if (qName.equals("players")) {
      curMission.setPlayers(curValue);
    } else if (qName.equals("time-limit")) {
      curMission.setTime(curValue, true);
    } else if (qName.equals("time")) {
      curMission.setTime(curValue, false);
    } else if (qName.equals("info")) {
      curMission.setInfo(curValue);
    } else if (qName.equals("mission")) {
      // Log.v(tag, "Adding mission " + curName + " (" + curMission.getName() + ")");
      data.put(curName, curMission);
      curName = "";
      curMission = null;
    } else if (qName.equals("details")) {
      mLoaded = true;
    }

    curValue = "";
  }
コード例 #2
0
ファイル: SAXHandler.java プロジェクト: rlm33/TPV-RASS
 /**
  * Class initializer: Populate a table to translate SAX attribute type names into JDOM attribute
  * type value (integer).
  *
  * <p><b>Note that all the mappings defined below are compliant with the SAX 2.0 specification
  * exception for "ENUMERATION" with is specific to Crimson 1.1.X and Xerces 2.0.0-betaX which
  * report attributes of enumerated types with a type "ENUMERATION" instead of the expected
  * "NMTOKEN".
  *
  * <p>Note also that Xerces 1.4.X is not SAX 2.0 compliant either but handling its case requires
  * {@link #getAttributeType specific code}.
  */
 static {
   attrNameToTypeMap.put("CDATA", new Integer(Attribute.CDATA_TYPE));
   attrNameToTypeMap.put("ID", new Integer(Attribute.ID_TYPE));
   attrNameToTypeMap.put("IDREF", new Integer(Attribute.IDREF_TYPE));
   attrNameToTypeMap.put("IDREFS", new Integer(Attribute.IDREFS_TYPE));
   attrNameToTypeMap.put("ENTITY", new Integer(Attribute.ENTITY_TYPE));
   attrNameToTypeMap.put("ENTITIES", new Integer(Attribute.ENTITIES_TYPE));
   attrNameToTypeMap.put("NMTOKEN", new Integer(Attribute.NMTOKEN_TYPE));
   attrNameToTypeMap.put("NMTOKENS", new Integer(Attribute.NMTOKENS_TYPE));
   attrNameToTypeMap.put("NOTATION", new Integer(Attribute.NOTATION_TYPE));
   attrNameToTypeMap.put("ENUMERATION", new Integer(Attribute.ENUMERATED_TYPE));
 }
コード例 #3
0
ファイル: SAXHandler.java プロジェクト: rlm33/TPV-RASS
  /**
   * This is called when the parser encounters an external entity declaration.
   *
   * @param name entity name
   * @param publicID public id
   * @param systemID system id
   * @throws SAXException when things go wrong
   */
  public void externalEntityDecl(String name, String publicID, String systemID)
      throws SAXException {
    // Store the public and system ids for the name
    externalEntities.put(name, new String[] {publicID, systemID});

    if (!inInternalSubset) return;

    internalSubset.append("  <!ENTITY ").append(name);
    appendExternalId(publicID, systemID);
    internalSubset.append(">\n");
  }
コード例 #4
0
ファイル: SAXHandler.java プロジェクト: rlm33/TPV-RASS
 /**
  * Returns the the JDOM Attribute type value from the SAX 2.0 attribute type string provided by
  * the parser.
  *
  * @param typeName <code>String</code> the SAX 2.0 attribute type string.
  * @return <code>int</code> the JDOM attribute type.
  * @see Attribute#setAttributeType
  * @see Attributes#getType
  */
 private static int getAttributeType(String typeName) {
   Integer type = (Integer) (attrNameToTypeMap.get(typeName));
   if (type == null) {
     if (typeName != null && typeName.length() > 0 && typeName.charAt(0) == '(') {
       // Xerces 1.4.X reports attributes of enumerated type with
       // a type string equals to the enumeration definition, i.e.
       // starting with a parenthesis.
       return Attribute.ENUMERATED_TYPE;
     } else {
       return Attribute.UNDECLARED_TYPE;
     }
   } else {
     return type.intValue();
   }
 }
コード例 #5
0
ファイル: SAXHandler.java プロジェクト: rlm33/TPV-RASS
  public void startEntity(String name) throws SAXException {
    entityDepth++;

    if (expand || entityDepth > 1) {
      // Short cut out if we're expanding or if we're nested
      return;
    }

    // A "[dtd]" entity indicates the beginning of the external subset
    if (name.equals("[dtd]")) {
      inInternalSubset = false;
      return;
    }

    // Ignore DTD references, and translate the standard 5
    if ((!inDTD)
        && (!name.equals("amp"))
        && (!name.equals("lt"))
        && (!name.equals("gt"))
        && (!name.equals("apos"))
        && (!name.equals("quot"))) {

      if (!expand) {
        String pub = null;
        String sys = null;
        String[] ids = (String[]) externalEntities.get(name);
        if (ids != null) {
          pub = ids[0]; // may be null, that's OK
          sys = ids[1]; // may be null, that's OK
        }
        /**
         * if no current element, this entity belongs to an attribute in these cases, it is an error
         * on the part of the parser to call startEntity but this will help in some cases. See
         * org/xml/sax/ext/LexicalHandler.html#startEntity(java.lang.String) for more information
         */
        if (!atRoot) {
          flushCharacters();
          EntityRef entity = factory.entityRef(name, pub, sys);

          // no way to tell if the entity was from an attribute or element so just assume element
          factory.addContent(getCurrentElement(), entity);
        }
        suppress = true;
      }
    }
  }
コード例 #6
0
 public MissionInfo getMission(String name) {
   return data.get(name);
 }