protected void finished() {
   logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():finished()"); // $NON-NLS-1$
   if (!_isParsedDataValid) return;
   if (_ad_vector.size() == 0) {
     // Schema defines at least one AD is required.
     _isParsedDataValid = false;
     logger.log(
         LogService.LOG_ERROR,
         NLS.bind(
             MetaTypeMsg.MISSING_ELEMENT,
             new Object[] {
               AD,
               OCD,
               elementId,
               _dp_url,
               _dp_bundle.getBundleId(),
               _dp_bundle.getSymbolicName()
             }));
     return;
   }
   // OCD gets all parsed ADs.
   Enumeration<AttributeDefinitionImpl> adKey = _ad_vector.elements();
   while (adKey.hasMoreElements()) {
     AttributeDefinitionImpl ad = adKey.nextElement();
     _ocd.addAttributeDefinition(ad, ad._isRequired);
   }
   _ocd.setIcons(icons);
   _parent_OCDs_hashtable.put(_refID, _ocd);
 }
Ejemplo n.º 2
0
  // 응용프로그램에서 이미지 출력을 하기 위한 메소드
  public void showImage() throws Exception {
    for (int i = 0; i < vUnparsedEntityDecl.size(); i++) {
      UnparsedEntityDecl ued = (UnparsedEntityDecl) vUnparsedEntityDecl.elementAt(i);
      URL urlImageFile = new URL(ued.systemId);
      String imageFile = URLDecoder.decode(urlImageFile.getFile(), "euc-kr");
      imageFile = imageFile.replaceAll("/C:", "C:");

      NotationDecl nd = (NotationDecl) hNotationDecl.get(ued.notationName);
      URL urlHelperProgram = new URL(nd.systemId);
      String helperProgram = URLDecoder.decode(urlHelperProgram.getFile(), "euc-kr");
      helperProgram = helperProgram.replaceAll("/C:", "C:");

      String command = helperProgram + " " + imageFile;
      System.out.println(command);
      Process process = Runtime.getRuntime().exec(command);
    }
  }
Ejemplo n.º 3
0
 /**
  * A nice ol' bubble sort. This is used because it has a passable performance when the list starts
  * off sorted.
  */
 public void sort() {
   synchronized (this) {
     boolean swap;
     do {
       swap = false;
       for (int i = 1; i < tracks.size(); i++) {
         Track lastTrack = (Track) tracks.elementAt(i - 1);
         Track track = (Track) tracks.elementAt(i);
         if (compare(lastTrack, track) > 0) {
           tracks.setElementAt(track, i - 1);
           tracks.setElementAt(lastTrack, i);
           swap = true;
         }
       }
     } while (swap);
   }
 }
    protected void finished() {

      logger.log(
          LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler():finished()"); // $NON-NLS-1$
      if (!_isParsedDataValid) return;
      int numOfValues = _optionValue_vector.size();
      _ad.setOption(_optionLabel_vector, _optionValue_vector, true);
      String[] values = _ad.getOptionValues();
      if (values == null) values = new String[0];
      if (numOfValues != values.length)
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.INVALID_OPTIONS_XML,
                new Object[] {
                  elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()
                }));

      if (ad_defaults_str != null) {
        _ad.setDefaultValue(ad_defaults_str, true);
        if (_ad.getDefaultValue() == null)
          logger.log(
              LogService.LOG_WARNING,
              NLS.bind(
                  MetaTypeMsg.INVALID_DEFAULTS_XML,
                  new Object[] {
                    ad_defaults_str,
                    elementId,
                    _dp_url,
                    _dp_bundle.getBundleId(),
                    _dp_bundle.getSymbolicName()
                  }));
      }

      _parent_ADs_vector.addElement(_ad);
    }
Ejemplo n.º 5
0
  private void applyUpdates() throws SAXException {
    // now handle any updates
    if (updates.size() > 0) {
      try {
        Object upd[];
        Iterator<?> i = updates.iterator();
        while (i.hasNext()) {
          upd = (Object[]) i.next();
          idx = ((Integer) upd[0]).intValue();

          if (!(lastval.equals(upd[1]))) {
            insertValue((String) (upd[1]));
          }
        }

        rs.updateRow();
      } catch (SQLException ex) {
        throw new SAXException(
            MessageFormat.format(
                resBundle.handleGetObject("xmlrch.errupdrow").toString(), ex.getMessage()));
      }
      updates.removeAllElements();
    }
  }
Ejemplo n.º 6
0
 public int runCsvImport() {
   int count = 0;
   try {
     int linecnt = 0;
     String[] header = null;
     ArrayList<String> fieldsInImport = new ArrayList<String>();
     BufferedReader f =
         new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding));
     String s;
     DataRecord dummyRecord = storageObject.createNewRecord();
     while ((s = f.readLine()) != null) {
       s = s.trim();
       if (s.length() == 0) {
         continue;
       }
       Vector<String> fields = splitFields(s);
       if (fields.size() > 0) {
         if (linecnt == 0) {
           // header
           header = new String[fields.size()];
           for (int i = 0; i < fields.size(); i++) {
             header[i] = fields.get(i);
             if (header[i].startsWith("#") && header[i].endsWith("#") && header.length > 2) {
               header[i] = header[i].substring(1, header[i].length() - 1).trim();
               overrideKeyField = header[i];
             }
             String[] equivFields = dummyRecord.getEquivalentFields(header[i]);
             for (String ef : equivFields) {
               fieldsInImport.add(ef);
             }
           }
         } else {
           // fields
           DataRecord r = storageObject.createNewRecord();
           for (int i = 0; i < header.length; i++) {
             String value = (fields.size() > i ? fields.get(i) : null);
             if (value != null && value.length() > 0) {
               try {
                 if (!r.setFromText(header[i], value.trim())) {
                   logImportWarning(
                       r,
                       "Value '"
                           + value
                           + "' for Field '"
                           + header[i]
                           + "' corrected to '"
                           + r.getAsText(header[i])
                           + "'");
                 }
               } catch (Exception esetvalue) {
                 logImportWarning(
                     r,
                     "Cannot set value '"
                         + value
                         + "' for Field '"
                         + header[i]
                         + "': "
                         + esetvalue.toString());
               }
             }
           }
           if (importRecord(r, fieldsInImport)) {
             count++;
           }
         }
       }
       linecnt++;
     }
     f.close();
   } catch (Exception e) {
     logInfo(e.toString());
     errorCount++;
     Logger.log(e);
     if (Daten.isGuiAppl()) {
       Dialog.error(e.toString());
     }
   }
   return count;
 }
Ejemplo n.º 7
0
 public int getNoOfTracks() {
   return tracks.size();
 }
Ejemplo n.º 8
0
 public void purge() {
   for (int i = tracks.size() - 1; i >= 0; i--) {
     Track track = (Track) tracks.elementAt(i);
     if (track.isHidden()) tracks.remove(i);
   }
 }
Ejemplo n.º 9
0
  /**
   * Sets the value for the given element if <code>name</code> is one of the array elements in the
   * fields <code>properties</code>, <code>colDef</code>, or <code>data</code> and this <code>
   * XmlReaderContentHandler</code> object's state is not <code>INITIAL</code>. If the state is
   * <code>INITIAL</code>, this method does nothing.
   *
   * <p>If the state is <code>METADATA</code> and the argument supplied is <code>"metadata"</code>,
   * the rowset's metadata is set. If the state is <code>PROPERTIES</code>, the appropriate property
   * is set using the given name to determine the appropriate value. If the state is <code>DATA
   * </code> and the argument supplied is <code>"data"</code>, this method sets the state to <code>
   * INITIAL</code> and returns. If the argument supplied is one of the elements in the field <code>
   * data</code>, this method makes the appropriate changes to the rowset's data.
   *
   * @param lName the name of the element; either (1) one of the array elements in the fields <code>
   *     properties</code>, <code>colDef</code>, or <code>data</code> or (2) one of the <code>RowSet
   *     </code> elements <code>"properties"</code>, <code>"metadata"</code>, or <code>"data"</code>
   * @exception SAXException if a general SAX error occurs
   */
  @SuppressWarnings("fallthrough")
  public void endElement(String uri, String lName, String qName) throws SAXException {
    int tag;

    String name = "";
    name = lName;

    switch (getState()) {
      case PROPERTIES:
        if (name.equals("properties")) {
          state = INITIAL;
          break;
        }

        try {
          tag = propMap.get(name);
          switch (tag) {
            case KeycolsTag:
              if (keyCols != null) {
                int i[] = new int[keyCols.size()];
                for (int j = 0; j < i.length; j++) i[j] = Integer.parseInt(keyCols.elementAt(j));
                rs.setKeyColumns(i);
              }
              break;

            case PropClassTag:
              // Added the handling for Class tags to take care of maps
              // Makes an entry into the map upon end of class tag
              try {
                typeMap.put(Key_map, j86.sun.reflect.misc.ReflectUtil.forName(Value_map));

              } catch (ClassNotFoundException ex) {
                throw new SAXException(
                    MessageFormat.format(
                        resBundle.handleGetObject("xmlrch.errmap").toString(), ex.getMessage()));
              }
              break;

            case MapTag:
              // Added the handling for Map to take set the typeMap
              rs.setTypeMap(typeMap);
              break;

            default:
              break;
          }

          if (getNullValue()) {
            setPropertyValue(null);
            setNullValue(false);
          } else {
            setPropertyValue(propertyValue);
          }
        } catch (SQLException ex) {
          throw new SAXException(ex.getMessage());
        }

        // propertyValue need to be reset to an empty string
        propertyValue = "";
        setTag(-1);
        break;
      case METADATA:
        if (name.equals("metadata")) {
          try {
            rs.setMetaData(md);
            state = INITIAL;
          } catch (SQLException ex) {
            throw new SAXException(
                MessageFormat.format(
                    resBundle.handleGetObject("xmlrch.errmetadata").toString(), ex.getMessage()));
          }
        } else {
          try {
            if (getNullValue()) {
              setMetaDataValue(null);
              setNullValue(false);
            } else {
              setMetaDataValue(metaDataValue);
            }
          } catch (SQLException ex) {
            throw new SAXException(
                MessageFormat.format(
                    resBundle.handleGetObject("xmlrch.errmetadata").toString(), ex.getMessage()));
          }
          // metaDataValue needs to be reset to an empty string
          metaDataValue = "";
        }
        setTag(-1);
        break;
      case DATA:
        if (name.equals("data")) {
          state = INITIAL;
          return;
        }

        if (dataMap.get(name) == null) {
          tag = NullTag;
        } else {
          tag = dataMap.get(name);
        }
        switch (tag) {
          case ColTag:
            try {
              idx++;
              if (getNullValue()) {
                insertValue(null);
                setNullValue(false);
              } else {
                insertValue(tempStr);
              }
              // columnValue now need to be reset to the empty string
              columnValue = "";
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errinsertval").toString(),
                      ex.getMessage()));
            }
            break;
          case RowTag:
            try {
              rs.insertRow();
              rs.moveToCurrentRow();
              rs.next();

              // Making this as the original to turn off the
              // rowInserted flagging
              rs.setOriginalRow();

              applyUpdates();
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errconstr").toString(), ex.getMessage()));
            }
            break;
          case DelTag:
            try {
              rs.insertRow();
              rs.moveToCurrentRow();
              rs.next();
              rs.setOriginalRow();
              applyUpdates();
              rs.deleteRow();
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errdel").toString(), ex.getMessage()));
            }
            break;
          case InsTag:
            try {
              rs.insertRow();
              rs.moveToCurrentRow();
              rs.next();
              applyUpdates();
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errinsert").toString(), ex.getMessage()));
            }
            break;

          case InsDelTag:
            try {
              rs.insertRow();
              rs.moveToCurrentRow();
              rs.next();
              rs.setOriginalRow();
              applyUpdates();
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errinsdel").toString(), ex.getMessage()));
            }
            break;

          case UpdTag:
            try {
              if (getNullValue()) {
                insertValue(null);
                setNullValue(false);
              } else if (getEmptyStringValue()) {
                insertValue("");
                setEmptyStringValue(false);
              } else {
                updates.add(upd);
              }
            } catch (SQLException ex) {
              throw new SAXException(
                  MessageFormat.format(
                      resBundle.handleGetObject("xmlrch.errupdate").toString(), ex.getMessage()));
            }
            break;

          default:
            break;
        }
      default:
        break;
    }
  }
Ejemplo n.º 10
0
  /**
   * Reads XML element(s) into an indexed bean property by first locating the XML element(s)
   * corresponding to this property.
   *
   * @param ob The bean whose property is being set
   * @param desc The property that will be set
   * @param nodes The list of XML items that may contain the property
   * @throws IOException If there is an error reading the document
   */
  public void readIndexedProperty(
      Object ob, IndexedPropertyDescriptor desc, NodeList nodes, NamedNodeMap attrs)
      throws IOException {
    // Create a vector to hold the property values
    Vector v = new Vector();

    int numAttrs = attrs.getLength();

    for (int i = 0; i < numAttrs; i++) {
      // See if this attribute matches the property name
      if (namesMatch(desc.getName(), attrs.item(i).getNodeName())) {
        // Get the property value
        Object obValue = getObjectValue(desc, attrs.item(i).getNodeValue());

        if (obValue != null) {
          // Add the value to the list of values to be set
          v.addElement(obValue);
        }
      }
    }

    int numNodes = nodes.getLength();

    for (int i = 0; i < numNodes; i++) {
      Node node = nodes.item(i);

      // Skip non-element nodes
      if (!(node instanceof Element)) continue;

      Element element = (Element) node;

      // See if this element tag matches the property name
      if (namesMatch(desc.getName(), element.getTagName())) {
        // Get the property value
        Object obValue = getObjectValue(desc, element);

        if (obValue != null) {
          // Add the value to the list of values to be set
          v.addElement(obValue);
        }
      }
    }

    // Get the method used to set the property value
    Method setter = desc.getWriteMethod();

    // If this property has no setter, don't write it
    if (setter == null) return;

    // Create a new array of property values
    Object propArray = Array.newInstance(desc.getPropertyType().getComponentType(), v.size());

    // Copy the vector into the array
    v.copyInto((Object[]) propArray);

    try {
      // Store the array of property values
      setter.invoke(ob, new Object[] {propArray});
    } catch (InvocationTargetException exc) {
      throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
    } catch (IllegalAccessException exc) {
      throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
    }
  }
Ejemplo n.º 11
0
  /**
   * Reads an XML element into a bean property by first locating the XML element corresponding to
   * this property.
   *
   * @param ob The bean whose property is being set
   * @param desc The property that will be set
   * @param nodes The list of XML items that may contain the property
   * @throws IOException If there is an error reading the document
   */
  public void readProperty(Object ob, PropertyDescriptor desc, NodeList nodes, NamedNodeMap attrs)
      throws IOException {
    int numAttrs = attrs.getLength();

    for (int i = 0; i < numAttrs; i++) {
      // See if the attribute name matches the property name
      if (namesMatch(desc.getName(), attrs.item(i).getNodeName())) {
        // Get the method used to set this property
        Method setter = desc.getWriteMethod();

        // If this object has no setter, don't bother writing it
        if (setter == null) continue;

        // Get the value of the property
        Object obValue = getObjectValue(desc, attrs.item(i).getNodeValue());
        if (obValue != null) {
          try {
            // Set the property value
            setter.invoke(ob, new Object[] {obValue});
          } catch (InvocationTargetException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          } catch (IllegalAccessException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          }
        }

        return;
      }
    }

    int numNodes = nodes.getLength();

    Vector arrayBuild = null;

    for (int i = 0; i < numNodes; i++) {
      Node node = nodes.item(i);

      // If this node isn't an element, skip it
      if (!(node instanceof Element)) continue;

      Element element = (Element) node;

      // See if the tag name matches the property name
      if (namesMatch(desc.getName(), element.getTagName())) {
        // Get the method used to set this property
        Method setter = desc.getWriteMethod();

        // If this object has no setter, don't bother writing it
        if (setter == null) continue;

        // Get the value of the property
        Object obValue = getObjectValue(desc, element);

        // 070201 MAW: Modified from change submitted by Steve Poulson
        if (setter.getParameterTypes()[0].isArray()) {
          if (arrayBuild == null) {
            arrayBuild = new Vector();
          }
          arrayBuild.addElement(obValue);

          // 070201 MAW: Go ahead and read through the rest of the nodes in case
          //             another one matches the array. This has the effect of skipping
          //             over the "return" statement down below
          continue;
        }

        if (obValue != null) {
          try {
            // Set the property value
            setter.invoke(ob, new Object[] {obValue});
          } catch (InvocationTargetException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          } catch (IllegalAccessException exc) {
            throw new IOException(
                "Error setting property " + desc.getName() + ": " + exc.toString());
          }
        }
        return;
      }
    }

    // If we build a vector of array members, convert the vector into
    // an array and save it in the property
    if (arrayBuild != null) {
      // Get the method used to set this property
      Method setter = desc.getWriteMethod();

      if (setter == null) return;

      Object[] obValues = (Object[]) Array.newInstance(desc.getPropertyType(), arrayBuild.size());

      arrayBuild.copyInto(obValues);

      try {
        setter.invoke(ob, new Object[] {obValues});
      } catch (InvocationTargetException exc) {
        throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
      } catch (IllegalAccessException exc) {
        throw new IOException("Error setting property " + desc.getName() + ": " + exc.toString());
      }

      return;
    }
  }