Exemple #1
0
  /**
   * Handle the declaration of a Notation in a DTD
   *
   * @param name name of the notation
   * @param publicID the public ID of the notation
   * @param systemID the system ID of the notation
   */
  public void notationDecl(String name, String publicID, String systemID) throws SAXException {

    if (!inInternalSubset) return;

    internalSubset.append("  <!NOTATION ").append(name);
    appendExternalId(publicID, systemID);
    internalSubset.append(">\n");
  }
Exemple #2
0
  /**
   * Handler for unparsed entity declarations in the DTD
   *
   * @param name <code>String</code> of the unparsed entity decl
   * @param publicID <code>String</code> of the unparsed entity decl
   * @param systemID <code>String</code> of the unparsed entity decl
   * @param notationName <code>String</code> of the unparsed entity decl
   */
  public void unparsedEntityDecl(String name, String publicID, String systemID, String notationName)
      throws SAXException {

    if (!inInternalSubset) return;

    internalSubset.append("  <!ENTITY ").append(name);
    appendExternalId(publicID, systemID);
    internalSubset.append(" NDATA ").append(notationName);
    internalSubset.append(">\n");
  }
Exemple #3
0
  /**
   * 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");
  }
Exemple #4
0
 /**
  * Appends an external ID to the internal subset buffer. Either publicID or systemID may be null,
  * but not both.
  *
  * @param publicID the public ID
  * @param systemID the system ID
  */
 private void appendExternalId(String publicID, String systemID) {
   if (publicID != null) {
     internalSubset.append(" PUBLIC \"").append(publicID).append('\"');
   }
   if (systemID != null) {
     if (publicID == null) {
       internalSubset.append(" SYSTEM ");
     } else {
       internalSubset.append(' ');
     }
     internalSubset.append('\"').append(systemID).append('\"');
   }
 }
Exemple #5
0
  /**
   * Handle an internal entity declaration in a DTD.
   *
   * @param name <code>String</code> name of entity
   * @param value <code>String</code> value of the entity
   * @throws SAXException
   */
  public void internalEntityDecl(String name, String value) throws SAXException {

    // Skip entities that come from the external subset
    if (!inInternalSubset) return;

    internalSubset.append("  <!ENTITY ");
    if (name.startsWith("%")) {
      internalSubset.append("% ").append(name.substring(1));
    } else {
      internalSubset.append(name);
    }
    internalSubset.append(" \"").append(value).append("\">\n");
  }
  /**
   * Process listuser from server
   *
   * @param doc
   */
  private void _listuser(Document doc) {
    StringBuffer userlist = new StringBuffer();

    Element root = doc.getRootElement();
    Element list = root.getChild("listuser");
    List users = list.getChildren("user");
    Iterator i = users.iterator();
    while (i.hasNext()) {
      userlist.append(((Element) i.next()).getText());
      userlist.append("\n");
    }
    sendMessage(SERVER, "Users: \n" + userlist);
  }
 public void visitDFS(Element current, StringBuffer b) {
   Element item = null;
   if (current == null) return;
   String tagName = current.getName();
   String tmp = "<" + tagName + ">" + current.getText();
   b.append(tmp);
   List children = current.getChildren();
   Iterator it = children.iterator();
   while (it.hasNext()) {
     item = (Element) it.next();
     if (item != null) {
       visitDFS(item, b);
     }
   }
   b.append("</" + tagName + ">\n");
 }
  /**
   * Process listgroup from server
   *
   * @param doc
   */
  private void _listgroup(Document doc) {
    StringBuffer grouplist = new StringBuffer();

    Element root = doc.getRootElement();
    Element list = root.getChild("listgroup");
    List groups = list.getChildren("group");
    Iterator i = groups.iterator();
    while (i.hasNext()) {
      Element temp = (Element) i.next();
      grouplist.append(temp.getChild("name").getText());
      grouplist.append("\t");
      grouplist.append(temp.getChild("description").getText());
      grouplist.append("\n");
    }
    sendMessage(SERVER, "Groups: \n" + grouplist);
  }
Exemple #9
0
  /**
   * This handles an attribute declaration in the internal subset.
   *
   * @param eName <code>String</code> element name of attribute
   * @param aName <code>String</code> attribute name
   * @param type <code>String</code> attribute type
   * @param valueDefault <code>String</code> default value of attribute
   * @param value <code>String</code> value of attribute
   * @throws SAXException
   */
  public void attributeDecl(
      String eName, String aName, String type, String valueDefault, String value)
      throws SAXException {

    if (!inInternalSubset) return;

    internalSubset
        .append("  <!ATTLIST ")
        .append(eName)
        .append(' ')
        .append(aName)
        .append(' ')
        .append(type)
        .append(' ');
    if (valueDefault != null) {
      internalSubset.append(valueDefault);
    } else {
      internalSubset.append('\"').append(value).append('\"');
    }
    if ((valueDefault != null) && (valueDefault.equals("#FIXED"))) {
      internalSubset.append(" \"").append(value).append('\"');
    }
    internalSubset.append(">\n");
  }
  private void logResultInfo(Query query, String queryResult) {
    StringBuffer sb = new StringBuffer();

    sb.append(
        "\n\n\tQuery "
            + query.getNr()
            + " of run "
            + (query.getQueryMix().getQueryMixRuns() + 1)
            + ":\n");
    sb.append("\n\tQuery string:\n\n");
    sb.append(query.getQueryString());
    sb.append("\n\n\tResult:\n\n");
    sb.append(queryResult);
    sb.append(
        "\n\n__________________________________________________________________________________\n");
    logger.log(Level.ALL, sb.toString());
  }
Exemple #11
0
  /**
   * This reports that a comments is parsed. If not in the DTD, this comment is added to the current
   * JDOM <code>Element</code>, or the <code>Document</code> itself if at that level.
   *
   * @param ch <code>ch[]</code> array of comment characters.
   * @param start <code>int</code> index to start reading from.
   * @param length <code>int</code> length of data.
   * @throws SAXException
   */
  public void comment(char[] ch, int start, int length) throws SAXException {

    if (suppress) return;

    flushCharacters();

    String commentText = new String(ch, start, length);
    if (inDTD && inInternalSubset && (expand == false)) {
      internalSubset.append("  <!--").append(commentText).append("-->\n");
      return;
    }
    if ((!inDTD) && (!commentText.equals(""))) {
      if (atRoot) {
        factory.addContent(document, factory.comment(commentText));
      } else {
        factory.addContent(getCurrentElement(), factory.comment(commentText));
      }
    }
  }
Exemple #12
0
  /**
   * This signifies that the reading of the DTD is complete.
   *
   * @throws SAXException
   */
  public void endDTD() throws SAXException {

    document.getDocType().setInternalSubset(internalSubset.toString());
    inDTD = false;
    inInternalSubset = false;
  }
 public String toString() {
   StringBuffer buf = new StringBuffer();
   Element root = doc.getRootElement();
   visitDFS(root, buf);
   return buf.toString();
 }
  private void logResultInfo(
      int queryNr,
      int queryMixRun,
      double timeInSeconds,
      String queryString,
      byte queryType,
      int resultCount) {
    StringBuffer sb = new StringBuffer(1000);
    sb.append("\n\n\tQuery " + queryNr + " of run " + queryMixRun + " has been executed ");
    sb.append("in " + String.format("%.6f", timeInSeconds) + " seconds.\n");
    sb.append("\n\tQuery string:\n\n");
    sb.append(queryString);
    sb.append("\n\n");

    // Log results
    if (queryType == Query.DESCRIBE_TYPE)
      sb.append("\tQuery(Describe) result (" + resultCount + " Bytes): \n\n");
    else if (queryType == Query.CONSTRUCT_TYPE)
      sb.append("\tQuery(Construct) result (" + resultCount + " Bytes): \n\n");
    else sb.append("\tQuery results (" + resultCount + " results): \n\n");

    sb.append(
        "\n__________________________________________________________________________________\n");
    logger.log(Level.ALL, sb.toString());
  }
Exemple #15
0
  public String getEnumType(String enumType, String fieldTitle) {

    try {
      EnumerationBean enumBean = EnumerationType.getEnu(enumType);

      // Iterator keys=enumBean.getEnu().keySet().iterator();
      Object[] keys = enumBean.getKeys().toArray();

      StringBuffer StrBuf = new StringBuffer();

      String[] fieldTitlearr = fieldTitle.split(",");

      StrBuf.append(
          "<table id='Data_dropDown' class=\"dropDownTable\"  width='100%' border='0'  cellspacing='1' cellpadding='1' >");

      StrBuf.append("<tr height='20'   class=\"dropDownHead\" >");

      for (int i = 0; i < fieldTitlearr.length; i++) {
        StrBuf.append("<td align=\"center\">" + fieldTitlearr[i] + "</td> ");
      }
      StrBuf.append("</tr>");

      for (int i = 0; i < keys.length; i++) {
        Object key = keys[i];

        StrBuf.append("<tr  onclick=\"TRClick(this)\" height='20' class=\"gridEvenRow\">");
        String[] enumStr = ((String) enumBean.getValue(key)).split(";");
        StrBuf.append("<td  align =\"left\" >" + key.toString() + "</td>");
        StrBuf.append("<td  align =\"left\" >" + enumStr[0] + "</td>");
        StrBuf.append("</tr>");
      }
      StrBuf.append("</table>");

      return StrBuf.toString();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
  }
Exemple #16
0
  public String getUserSerial(String operID) {

    ConnectionManager cm = ConnectionManager.getInstance();

    String userSerial = Util.getUserSerial(cm.getConnection(), operID);

    StringBuffer StrBuf = new StringBuffer();

    StrBuf.append("<root>");
    StrBuf.append("<action type=\"1\" result=\"true\">");

    StrBuf.append("<record> ");

    StrBuf.append("<field ");
    StrBuf.append(" name =\"userserial\"");
    StrBuf.append(" type =\"text\"");
    StrBuf.append("  value =\"" + userSerial + "\"");
    StrBuf.append(" />");
    StrBuf.append("</record>");
    StrBuf.append("</action>");

    StrBuf.append("</root>");

    cm.release();
    return StrBuf.toString();
  }
Exemple #17
0
  /**
   * Handle an element declaration in a DTD.
   *
   * @param name <code>String</code> name of element
   * @param model <code>String</code> model of the element in DTD syntax
   * @throws SAXException
   */
  public void elementDecl(String name, String model) throws SAXException {
    // Skip elements that come from the external subset
    if (!inInternalSubset) return;

    internalSubset.append("  <!ELEMENT ").append(name).append(' ').append(model).append(">\n");
  }