/**
   * Read the version information from a file with a given file name. The file must be a jar
   * manifest file and all its entries are searched for package names and their specification
   * version information. All information is collected in a map for later lookup of package names
   * and their versions.
   *
   * @param versionFileName name of the jar file containing version information
   */
  public static String readVersionFromFile(String applicationName, String versionFileName) {
    try {
      FileInputStream fileInput = new FileInputStream(versionFileName);
      Manifest manifest = new Manifest();
      manifest.read(fileInput);

      Map entries = manifest.getEntries();
      // Now write out the pre-entry attributes
      Iterator entryIterator = entries.entrySet().iterator();
      while (entryIterator.hasNext()) {
        Map.Entry currentEntry = (Map.Entry) entryIterator.next();
        String packageName = currentEntry.getKey().toString();
        packageName = normalizePackageName(packageName);
        Attributes attributes = (Attributes) currentEntry.getValue();
        String packageSpecVersion = attributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
        packageSpecVersion = extractVersionInfo(packageSpecVersion);
        return packageSpecVersion;
      }
    } catch (IOException exception) {
      exception.printStackTrace();
    }

    // no version found
    return null;
  }
Exemple #2
0
  public static String saxElementToDebugString(String uri, String qName, Attributes attributes) {
    // Open start tag
    final StringBuilder sb = new StringBuilder("<");
    sb.append(qName);

    final Set<String> declaredPrefixes = new HashSet<String>();
    mapPrefixIfNeeded(declaredPrefixes, uri, qName, sb);

    // Attributes if any
    for (int i = 0; i < attributes.getLength(); i++) {
      mapPrefixIfNeeded(declaredPrefixes, attributes.getURI(i), attributes.getQName(i), sb);

      sb.append(' ');
      sb.append(attributes.getQName(i));
      sb.append("=\"");
      sb.append(attributes.getValue(i));
      sb.append('\"');
    }

    // Close start tag
    sb.append('>');

    // Content
    sb.append("[...]");

    // Close element with end tag
    sb.append("</");
    sb.append(qName);
    sb.append('>');

    return sb.toString();
  }
Exemple #3
0
  /**
   * Returs the type of the dataset 0-Modelling, 1-Clasiffication, 2-Clustering
   *
   * @return type of the dataset 0-Modelling, 1-Clasiffication, 2-Clustering
   */
  public int datasetType() {

    if (Attributes.getOutputNumAttributes() >= 1) {
      if (Attributes.hasNominalAttributes()) return (1);
      else return (0);
    } else return (2);
  }
    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);
    }
Exemple #5
0
 /**
  * Returns the manifest value for the specified key.
  *
  * @param key key
  * @return value or {@code null}
  */
 public static Object get(final String key) {
   if (MAP != null) {
     for (final Object o : MAP.keySet()) {
       if (key.equals(o.toString())) return MAP.get(o);
     }
   }
   return null;
 }
Exemple #6
0
 private void addCreatedBy(Manifest m) {
   Attributes global = m.getMainAttributes();
   if (global.getValue(new Attributes.Name("Created-By")) == null) {
     String javaVendor = System.getProperty("java.vendor");
     String jdkVersion = System.getProperty("java.version");
     global.put(new Attributes.Name("Created-By"), jdkVersion + " (" + javaVendor + ")");
   }
 }
 private String version(String jarPath) throws IOException {
   Attributes attributes = getManifestAttributes(jarPath);
   if (attributes == null) {
     log.trace("no main attributes in manifest {}", jarPath);
     return null;
   }
   String version = attributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
   log.trace("found specification version {}", version);
   return version;
 }
 public Attributes getAttributes() throws IOException {
   if (URLJarFile.this.isSuperMan()) {
     Map e = URLJarFile.this.superEntries;
     if (e != null) {
       Attributes a = (Attributes) e.get(getName());
       if (a != null) return (Attributes) a.clone();
     }
   }
   return null;
 }
Exemple #9
0
  /**
   * Generating the header of the output file @ param p PrintStream
   *
   * @return Nothing
   */
  private void CopyHeaderTest(PrintStream p) {

    // Header of the output file
    p.println("@relation " + Attributes.getRelationName());
    p.print(Attributes.getInputAttributesHeader());
    p.print(Attributes.getOutputAttributesHeader());
    p.println(Attributes.getInputHeader());
    p.println(Attributes.getOutputHeader());
    p.println("@data");
  }
Exemple #10
0
 private boolean isAmbiguousMainClass(Manifest m) {
   if (ename != null) {
     Attributes global = m.getMainAttributes();
     if ((global.get(Attributes.Name.MAIN_CLASS) != null)) {
       error(getMsg("error.bad.eflag"));
       usageError();
       return true;
     }
   }
   return false;
 }
    public void init(
        String name, Attributes atts, Hashtable<String, ObjectClassDefinitionImpl> ocds_hashtable) {

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

      String ocd_description_val = atts.getValue(DESCRIPTION);
      if (ocd_description_val == null) {
        // Not a problem, because DESCRIPTION is an optional attribute.
      }

      _refID = atts.getValue(ID);
      if (_refID == null) {
        _isParsedDataValid = false;
        logger.log(
            LogService.LOG_ERROR,
            NLS.bind(
                MetaTypeMsg.MISSING_ATTRIBUTE,
                new Object[] {
                  ID,
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
        return;
      }

      _ocd =
          new ObjectClassDefinitionImpl(
              ocd_name_val, ocd_description_val, _refID, _dp_localization, extensionAttributes);
    }
Exemple #12
0
 private static Hashtable<String, String> getManifestAttributes(Manifest manifest) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   try {
     Attributes attrs = manifest.getMainAttributes();
     Iterator it = attrs.keySet().iterator();
     while (it.hasNext()) {
       String key = it.next().toString();
       h.put(key, attrs.getValue(key));
     }
   } catch (Exception ignore) {
   }
   return h;
 }
Exemple #13
0
  /**
   * Process a dataset for classification
   *
   * @return Nothing
   */
  public void processClassifierDataset() throws IOException {
    try {

      ndata = IS.getNumInstances();
      ninputs = Attributes.getInputNumAttributes();
      nvariables = ninputs + Attributes.getOutputNumAttributes();
      // Check that there is only one output variable and
      // it is nominal
      if (Attributes.getOutputNumAttributes() > 1) {
        System.out.println("This algorithm can not process MIMO datasets");
        System.out.println("All outputs but the first one will be removed");
      }
      boolean noOutputs = false;
      if (Attributes.getOutputNumAttributes() < 1) {
        System.out.println("This algorithm cannot process datasets without outputs");
        System.out.println("Zero-valued output generated");
        noOutputs = true;
      }
      // Initialice and fill our own tables
      X = new double[ndata][ninputs];
      missing = new boolean[ndata][ninputs];
      C = new int[ndata];
      // Maximum and minimum of inputs
      imax = new double[ninputs];
      imin = new double[ninputs];
      // Maximum and minimum for output data
      omax = 0;
      omin = 0;
      // All values are casted into double/integer
      nclasses = 0;
      for (int i = 0; i < X.length; i++) {
        Instance inst = IS.getInstance(i);
        for (int j = 0; j < ninputs; j++) {
          X[i][j] = IS.getInputNumericValue(i, j);
          missing[i][j] = inst.getInputMissingValues(j);
          if (X[i][j] > imax[j] || i == 0) imax[j] = X[i][j];
          if (X[i][j] < imin[j] || i == 0) imin[j] = X[i][j];
        }
        if (noOutputs) C[i] = 0;
        else C[i] = (int) IS.getOutputNumericValue(i, 0);
        if (C[i] > nclasses) nclasses = C[i];
      }
      nclasses++;
      System.out.println("Number of classes=" + nclasses);
    } catch (Exception e) {
      System.out.println("DBG: Exception in readSet");
      e.printStackTrace();
    }
  }
Exemple #14
0
  /**
   * Process a dataset file for a clustering problem.
   *
   * @param nfexamples Name of the dataset file
   * @param train The dataset file is for training or for test
   * @throws java.io.IOException if there is any semantical, lexical or sintactical error in the
   *     input file.
   */
  public void processClusterDataset(String nfexamples, boolean train) throws IOException {

    try {

      // Load in memory a dataset that contains a classification problem
      IS.readSet(nfexamples, train);

      nData = IS.getNumInstances();
      nInputs = Attributes.getInputNumAttributes();
      nVariables = nInputs + Attributes.getOutputNumAttributes();

      if (Attributes.getOutputNumAttributes() != 0) {
        System.out.println("This algorithm can not process datasets with outputs");
        System.out.println("All outputs will be removed");
      }

      // Initialize and fill our own tables
      X = new double[nData][nInputs];
      missing = new boolean[nData][nInputs];

      // Maximum and minimum of inputs
      iMaximum = new double[nInputs];
      iMinimum = new double[nInputs];

      // Maximum and minimum for output data
      oMaximum = 0;
      oMinimum = 0;

      // All values are casted into double/integer
      nClasses = 0;
      for (int i = 0; i < X.length; i++) {
        Instance inst = IS.getInstance(i);
        for (int j = 0; j < nInputs; j++) {
          X[i][j] = IS.getInputNumericValue(i, j);
          missing[i][j] = inst.getInputMissingValues(j);
          if (X[i][j] > iMaximum[j] || i == 0) {
            iMaximum[j] = X[i][j];
          }
          if (X[i][j] < iMinimum[j] || i == 0) {
            iMinimum[j] = X[i][j];
          }
        }
      }

    } catch (Exception e) {
      System.out.println("DBG: Exception in readSet");
      e.printStackTrace();
    }
  }
 protected void collectExtensionAttributes(Attributes attributes) {
   for (int i = 0; i < attributes.getLength(); i++) {
     String key = attributes.getURI(i);
     if (key.length() == 0
         || key.startsWith("http://www.osgi.org/xmlns/metatype/v")) // $NON-NLS-1$
     continue;
     Map<String, String> value = extensionAttributes.get(key);
     if (value == null) {
       value = new HashMap<String, String>();
       extensionAttributes.put(key, value);
     }
     value.put(
         getName(attributes.getLocalName(i), attributes.getQName(i)), attributes.getValue(i));
   }
 }
Exemple #16
0
  /**
   * Process a dataset for modelling
   *
   * @return Nothing
   */
  public void processModelDataset() throws IOException {
    try {

      // Load in memory a dataset that contains a classification problem
      // IS.readSet(nfejemplos,train);
      ndata = IS.getNumInstances();
      ninputs = Attributes.getInputNumAttributes();
      nvariables = ninputs + Attributes.getOutputNumAttributes();
      if (Attributes.getOutputNumAttributes() > 1) {
        System.out.println("This algorithm can not process MIMO datasets");
        System.out.println("All outputs but the first one will be removed");
      }
      boolean noOutputs = false;
      if (Attributes.getOutputNumAttributes() < 1) {
        System.out.println("This algorithm can not process datasets without outputs");
        System.out.println("Zero-valued output generated");
        noOutputs = true;
      }
      // Initialice and fill our own tables
      X = new double[ndata][ninputs];
      missing = new boolean[ndata][ninputs];
      Y = new double[ndata];
      // Maximum and minimum of inputs
      imax = new double[ninputs];
      imin = new double[ninputs];
      // Maximum and minimum for output data
      omax = 0;
      omin = 0;
      // All values are casted into double/integer
      nclasses = 0;
      for (int i = 0; i < X.length; i++) {
        Instance inst = IS.getInstance(i);
        for (int j = 0; j < ninputs; j++) {
          X[i][j] = IS.getInputNumericValue(i, j);
          missing[i][j] = inst.getInputMissingValues(j);
          if (X[i][j] > imax[j] || i == 0) imax[j] = X[i][j];
          if (X[i][j] < imin[j] || i == 0) imin[j] = X[i][j];
        }
        if (noOutputs) Y[i] = 0;
        else Y[i] = IS.getOutputNumericValue(i, 0);
        if (Y[i] > omax || i == 0) omax = Y[i];
        if (Y[i] < omin || i == 0) omin = Y[i];
      }
    } catch (Exception e) {
      System.out.println("DBG: Exception in readSet");
      e.printStackTrace();
    }
  }
  public void startElement(
      String namespaceURI,
      String sName, // simple name
      String qName, // qualified name
      Attributes attrs)
      throws SAXException {
    echoText();
    indentLevel++;
    nl();

    String eName = sName; // element name

    if ("".equals(eName)) {
      eName = qName; // not namespaceAware
    }

    emit("<" + eName);

    if (eName.equals("error_code")) {
      // hit an error
      error = true;
      error_codeFlag = true;
    } else if (eName.equals("error_text")) {
      error_textFlag = true;
    }

    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);
        }

        if (!aName.equals("xmlns")
            && !aName.equals("xmlns:xsi")
            && !aName.equals("xsi:schemaLocation")) {
          emit(" ");
          emit(aName);
          emit(" = \"");
          emit(attrs.getValue(i));
          emit("\"");
        }
      }
    }

    emit(">");
  }
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is DesignateHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(OBJECT)) {
        ObjectHandler objectHandler = new ObjectHandler(this);
        objectHandler.init(name, atts);
        if (objectHandler._isParsedDataValid) {
          _ocdref = objectHandler._ocdref;
        }
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
Exemple #19
0
  void insertInputOutput(
      String line, int lineCount, Vector collection, String type, boolean isTrain) {
    String attName;

    System.out.println(" >> processing: " + line);

    // Declaring StringTokenizer
    StringTokenizer st = new StringTokenizer(line, ",");

    while (st.hasMoreTokens()) {
      attName = st.nextToken().trim();

      if (Attributes.getAttribute(attName) == null) {
        // If this attribute has not been declared, generate error
        ErrorInfo er =
            new ErrorInfo(
                ErrorInfo.InputTestAttributeNotDefined,
                0,
                lineCount,
                0,
                0,
                isTrain,
                ("The attribute "
                    + attName
                    + " defined in @"
                    + type
                    + " in test, it has not been defined in @inputs in its train dataset. It will be ignored"));
        InstanceSet.errorLogger.setError(er);
      } else {
        System.out.println("   > " + type + " attribute considered: " + attName + ".");
        collection.add(attName);
      }
    }
  } // end insertInputOutput
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(OPTION)) {
        OptionHandler optionHandler = new OptionHandler(this);
        optionHandler.init(name, atts);
        if (optionHandler._isParsedDataValid) {
          // Only add valid Option
          _optionLabel_vector.addElement(optionHandler._label_val);
          _optionValue_vector.addElement(optionHandler._value_val);
        }
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is OcdHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(AD)) {
        AttributeDefinitionHandler attributeDefHandler = new AttributeDefinitionHandler(this);
        attributeDefHandler.init(name, atts, _ad_vector);
      } else if (name.equalsIgnoreCase(ICON)) {
        IconHandler iconHandler = new IconHandler(this);
        iconHandler.init(name, atts);
        if (iconHandler._isParsedDataValid) icons.add(iconHandler._icon);
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is ObjectHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(ATTRIBUTE)) {
        AttributeHandler attributeHandler = new AttributeHandler(this);
        attributeHandler.init(name, atts);
        // The ATTRIBUTE element is only used by RFC94, do nothing for it here.
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is MetaDataHandler:startElement():" //$NON-NLS-1$
              + qName);
      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(DESIGNATE)) {
        DesignateHandler designateHandler = new DesignateHandler(this);
        designateHandler.init(name, atts);
        if (designateHandler._isParsedDataValid) {
          _dp_designateHandlers.addElement(designateHandler);
        }
      } else if (name.equalsIgnoreCase(OCD)) {
        OcdHandler ocdHandler = new OcdHandler(this);
        ocdHandler.init(name, atts, _dp_OCDs);
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
Exemple #24
0
  /**
   * Generates output file for a clasification problem @ param Foutput Name of the output file @
   * param real Vector of outputs instances @ param obtained Vector of net outputs
   *
   * @return Nothing
   */
  public void generateResultsClasification(String Foutput, int[] real, int[] obtained) {

    // Output file, classification problems
    FileOutputStream out;
    PrintStream p;
    Attribute at = Attributes.getOutputAttribute(0);

    // Check whether the output value is nominal or integer
    boolean isNominal = (at.getType() == at.NOMINAL);
    try {
      out = new FileOutputStream(Foutput);
      p = new PrintStream(out);
      CopyHeaderTest(p);
      // System.out.println("Longitudes "+real.length+" "+obtained.length);
      for (int i = 0; i < real.length; i++) {
        // Write the label associated to the class number,
        // when the output is nominal
        if (isNominal)
          p.print(at.getNominalValue(real[i]) + " " + at.getNominalValue(obtained[i]) + "\n");
        else p.print(real[i] + " " + obtained[i] + "\n");
      }
      p.close();
    } catch (Exception e) {
      System.err.println("Error building file for results: " + Foutput);
    }
  }
    public void startElement(String namespaceURI, String localName, String rawName, Attributes atts)
        throws SAXException {
      String k;

      if (insidePerson = (rawName.equals("author") || rawName.equals("editor"))) {
        Value = "";
        return;
      }
      if (insidePerson = (rawName.equals("booktitle") || rawName.equals("journal"))) {
        Value = "";
        return;
      }
      if ((atts.getLength() > 0) && ((k = atts.getValue("key")) != null)) {
        key = k;
        recordTag = rawName;
      }
    }
Exemple #26
0
    public void startElement(String uri, String localName, String qname, Attributes atts) {
      super.startElement(uri, localName, qname, atts);

      if (localName.equals(DataExport.FIELD_EXPORT)) {
        String type = atts.getValue(DataExport.EXPORT_TYPE);
        textImport = (type != null && type.equals(DataExport.EXPORT_TYPE_TEXT));
      } else if (localName.equals(DataRecord.ENCODING_RECORD)) {
        // begin of record
        record = dataAccess.getPersistence().createNewRecord();
        fieldsInImport = new ArrayList<String>();
        return;
      } else {
        if (atts.getValue("key") != null && atts.getValue("key").equalsIgnoreCase("true")) {
          overrideKeyField = localName;
        }
      }
    }
  public static void s_fill(Manifest man) {
    String strMethod = _f_s_strClass + "s_fill(man)";

    if (man == null) {
      MySystem.s_printOutExit(strMethod, "nil man");
    }

    Attributes attAttributes = man.getMainAttributes();

    attAttributes.putValue(
        S_Manifest._f_s_strsDefaultEntryManifVersion[0],
        S_Manifest._f_s_strsDefaultEntryManifVersion[1]);

    attAttributes.putValue(
        S_Manifest._f_s_strsDefaultEntryManifCreator[0],
        S_Manifest._f_s_strsDefaultEntryManifCreator[1]);
  }
Exemple #28
0
 private Map attributeMap(String tagName, Attributes atts) throws ParserException {
   if (null == tagName || null == atts) return null;
   Map mapping = null;
   try {
     mapping = (Map) attributeMaps.get(tagName);
   } catch (Exception e) {
     throw new ParserException(
         "Typecast error, unknown element found in attribute list mappings! " + e.getMessage());
   }
   if (null == mapping) return null;
   Map resultMapping = new HashMap();
   for (int i = 0; i < atts.getLength(); i++) {
     String xmlName = atts.getQName(i);
     String value = atts.getValue(i);
     TagMap.AttributeMapping aMap = null;
     try {
       aMap = (TagMap.AttributeMapping) mapping.get(xmlName);
     } catch (Exception e) {
       throw new ParserException(
           "Typecast error, unknown element found in property mapping! " + e.getMessage());
     }
     if (null == aMap)
       throw new ParserException(
           "No attribute mapping specified for attribute: " + xmlName + " in tag: " + tagName);
     String propertyName = aMap.getPropertyName();
     try {
       resultMapping.put(propertyName, aMap.convertValue(value));
     } catch (Exception e) {
       throw new ParserException(
           "Can not convert given value: \""
               + value
               + "\" to specified type: "
               + aMap.getType()
               + " for attribute: "
               + xmlName
               + " in tag: "
               + tagName
               + "! "
               + e.getMessage());
     }
   }
   checkForRequiredAttributes(tagName, resultMapping, mapping);
   addDefaultValues(resultMapping, mapping);
   return resultMapping;
 }
Exemple #29
0
  /** It does return the original header definiton but without @input and @output in there */
  public String getOriginalHeaderWithoutInOut() {
    String line = "";
    Attribute[] attrs = null;

    // Getting the relation name and the attributes
    if (storeAttributesAsNonStatic && attributes != null) {
      line = "@relation " + attributes.getRelationName() + "\n";
      attrs = attributes.getAttributes();
    } else {
      line = "@relation " + Attributes.getRelationName() + "\n";
      attrs = Attributes.getAttributes();
    }

    for (int i = 0; i < attrs.length; i++) {
      line += attrs[i].toString() + "\n";
    }
    return line;
  } // end getOriginalHeaderWithoutInOut
 public void startElement(
     String namespaceURI,
     String lName, // local name
     String qName, // qualified name
     Attributes attrs)
     throws SAXException {
   element = qName;
   if (element.compareToIgnoreCase("presence") == 0) {
     presenceTag = new PresenceTag();
     String entity = attrs.getValue("entity").trim();
     presenceTag.setEntity(entity);
   }
   if (element.compareToIgnoreCase("presentity") == 0) {
     presentityTag = new PresentityTag();
     String id = attrs.getValue("id").trim();
     presentityTag.setId(id);
   }
   if (element.compareToIgnoreCase("tuple") == 0) {
     tupleTag = new TupleTag();
     String id = attrs.getValue("id").trim();
     tupleTag.setId(id);
   }
   if (element.compareToIgnoreCase("status") == 0) {
     statusTag = new StatusTag();
   }
   if (element.compareToIgnoreCase("basic") == 0) {
     basicTag = new BasicTag();
   }
   if (element.compareToIgnoreCase("contact") == 0) {
     contactTag = new ContactTag();
     String priority = attrs.getValue("priority").trim();
     if (priority != null) {
       try {
         contactTag.setPriority(Float.parseFloat(priority));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   if (element.compareToIgnoreCase("note") == 0) {
     noteTag = new NoteTag();
   }
 }