예제 #1
0
    /** Map publicid to a resource accessible by a classloader. */
    public void registerCatalogEntry(String publicId, String resourceName, ClassLoader loader) {
      if (id2resource == null) id2resource = new Hashtable(17);
      id2resource.put(publicId, resourceName);

      if (loader != null) {
        if (id2loader == null) id2loader = new Hashtable(17);
        id2loader.put(publicId, loader);
      }
    }
예제 #2
0
  public static Hashtable getNodes(Model m) throws ModelException {

    Hashtable t = new Hashtable();
    for (Enumeration en = m.elements(); en.hasMoreElements(); ) {
      Statement s = (Statement) en.nextElement();
      t.put(s.subject(), s.subject());
      t.put(s.object(), s.object());
    }
    return t;
  }
예제 #3
0
    // return the resource as a stream
    private InputStream mapResource(String publicId) {
      if (publicId == null || id2resource == null) return null;

      String resourceName = (String) id2resource.get(publicId);
      ClassLoader loader = null;

      if (resourceName == null) return null;

      if (id2loader != null) loader = (ClassLoader) id2loader.get(publicId);

      if (loader == null) return ClassLoader.getSystemResourceAsStream(resourceName);
      return loader.getResourceAsStream(resourceName);
    }
 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);
 }
예제 #5
0
 public void remove(Track track) {
   synchronized (this) {
     docElt.removeChild(track.getElement());
     tracks.remove(track);
     hash.remove(track.getKey());
   }
 }
예제 #6
0
 public Track add(Track track) {
   synchronized (this) {
     Track copy;
     if ((copy = getTrack(track)) == null) {
       copy = new Track((Element) doc.importNode(track.getElement(), false));
       docElt.appendChild(copy.getElement());
       tracks.add(copy);
       hash.put(copy.getKey(), copy);
     }
     return copy;
   }
 }
예제 #7
0
  /**
   * Reads the children of an XML element and matches them to properties of a bean.
   *
   * @param ob The bean to receive the values
   * @param element The element the corresponds to the bean
   * @throws IOException If there is an error reading the document
   */
  public void readObject(Object ob, Element element) throws IOException {
    // If the object is null, skip the element
    if (ob == null) {
      return;
    }

    try {
      BeanInfo info = (BeanInfo) beanCache.get(ob.getClass());

      if (info == null) {
        // Get the bean info for the object
        info = Introspector.getBeanInfo(ob.getClass(), Object.class);

        beanCache.put(ob.getClass(), info);
      }

      // Get the object's properties
      PropertyDescriptor[] props = info.getPropertyDescriptors();

      // Get the attributes of the node
      NamedNodeMap attrs = element.getAttributes();

      // Get the children of the XML element
      NodeList nodes = element.getChildNodes();

      int numNodes = nodes.getLength();

      for (int i = 0; i < props.length; i++) {
        // Treat indexed properties a little differently
        if (props[i] instanceof IndexedPropertyDescriptor) {
          readIndexedProperty(ob, (IndexedPropertyDescriptor) props[i], nodes, attrs);
        } else {
          readProperty(ob, props[i], nodes, attrs);
        }
      }
    } catch (IntrospectionException exc) {
      throw new IOException(
          "Error getting bean info for " + ob.getClass().getName() + ": " + exc.toString());
    }
  }
예제 #8
0
 public void load(InputStream is) throws IOException, ParserConfigurationException, SAXException {
   doc = db.parse(is);
   docElt = doc.getDocumentElement();
   if (docElt.getTagName().equals(docElementName)) {
     NodeList nl = docElt.getElementsByTagName(trackElementName);
     for (int i = 0; i < nl.getLength(); i++) {
       Element elt = (Element) nl.item(i);
       Track track = new Track(elt);
       tracks.add(track);
       hash.put(track.getKey(), track);
     }
   }
 }
예제 #9
0
 public static void loadDict(String strDict) {
   try {
     BufferedReader br = new BufferedReader(new FileReader(strDict));
     String line = null;
     while ((line = br.readLine()) != null) {
       int idx = line.indexOf(',');
       if (idx > 0) {
         htDict.put(line.substring(0, idx), line.substring(idx + 1));
       }
     }
   } catch (FileNotFoundException fnfe) {
     fnfe.printStackTrace(System.out);
   } catch (IOException ioe) {
     ioe.printStackTrace(System.out);
   }
 }
예제 #10
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);
    }
  }
예제 #11
0
    /** SAX entity resolver */
    public InputSource resolveEntity(String name, String uri) throws IOException, SAXException {

      InputSource retval;
      String mappedURI = name2uri(name);
      InputStream stream = mapResource(name);

      // prefer explicit URI mappings, then bundled resources...
      if (mappedURI != null) {
        retval = new InputSource(mappedURI);
        retval.setPublicId(name);
        return retval;

      } else if (stream != null) {
        uri = "java:resource:" + (String) id2resource.get(name); // NOI18N
        retval = new InputSource(stream);
        retval.setPublicId(name);
        return retval;

      } else {
        return null;
      }
    }
예제 #12
0
 public Track getTrack(String key) {
   return (Track) hash.get(key);
 }
예제 #13
0
 // Notation 선언을 만났을 때 발생하는 이벤트를 처리하는 메소드
 public void notationDecl(String name, String publicId, String systemId) throws SAXException {
   NotationDecl nd = new NotationDecl(name, publicId, systemId);
   hNotationDecl.put(name, nd);
 }
예제 #14
0
  public static PetriNet convert(ConfigurableEPC baseEPC) {
    HashMap<EPCFunction, Transition> functionActivityMapping;
    HashMap<EPCConnector, Place> xorconnectorChoiceMapping;

    // HV: Initialize the mappings.
    functionActivityMapping = new HashMap<EPCFunction, Transition>();
    xorconnectorChoiceMapping = new HashMap<EPCConnector, Place>();

    // Check to use the weights if necessary
    // HV: Add both mappings. On completion, these will be filledd.
    PetriNet petrinet =
        EPCToPetriNetConverter.convert(
            baseEPC, new HashMap(), functionActivityMapping, xorconnectorChoiceMapping);

    HashSet visible = new HashSet();

    // HV: The next block is taken care of by the functionActivityMapping
    // below.
    /*
     * Iterator it = petrinet.getTransitions().iterator(); while
     * (it.hasNext()) { Transition t = (Transition) it.next(); if (t.object
     * instanceof EPCFunction) { // if (t.getLogEvent() != null) { // Add
     * transitions with LogEvent (i.e. referring to functions)
     * visible.add(t); } }
     */

    // HV: Prevent the places mapped onto from being reduced.
    visible.addAll(functionActivityMapping.values());
    visible.addAll(xorconnectorChoiceMapping.values());
    Message.add(visible.toString(), Message.DEBUG);

    Iterator it = petrinet.getPlaces().iterator();
    while (it.hasNext()) {
      Place p = (Place) it.next();
      if (p.inDegree() * p.outDegree() == 0) {
        // Add Initial and final places to visible, i.e. places that
        // refer to in and output events
        visible.add(p);
      }
    }

    // Reduce the PetriNet with Murata rules, while keeping the visible ones
    PetriNetReduction pnred = new PetriNetReduction();
    pnred.setNonReducableNodes(visible);

    HashMap pnMap = new HashMap(); // Used to map pre-reduction nodes to
    // post-reduction nodes.
    PetriNet reduced = pnred.reduce(petrinet, pnMap);

    if (reduced != petrinet) {
      // Update both mappings from pre-reduction nodes to post-reduction
      // nodes.
      HashMap<EPCFunction, Transition> newFunctionActivityMapping =
          new HashMap<EPCFunction, Transition>();
      for (EPCFunction function : functionActivityMapping.keySet()) {
        Transition transition = (Transition) functionActivityMapping.get(function);
        if (pnMap.keySet().contains(transition)) {
          newFunctionActivityMapping.put(function, (Transition) pnMap.get(transition));
        }
      }
      functionActivityMapping = newFunctionActivityMapping;
      HashMap<EPCConnector, Place> newXorconnectorChoiceMapping =
          new HashMap<EPCConnector, Place>();
      for (EPCConnector connector : xorconnectorChoiceMapping.keySet()) {
        Place place = (Place) xorconnectorChoiceMapping.get(connector);
        if (pnMap.keySet().contains(place)) {
          newXorconnectorChoiceMapping.put(connector, (Place) pnMap.get(place));
        }
      }
      xorconnectorChoiceMapping = newXorconnectorChoiceMapping;
    }
    reduced.makeClusters();

    // filter the \nunknown:normal
    ArrayList<Transition> alTrans = reduced.getVisibleTasks();
    for (int i = 0; i < alTrans.size(); i++) {
      Transition t = alTrans.get(i);
      String id = t.getIdentifier();
      int idx = id.indexOf("\\nunknown:normal");
      if (idx > 0) {
        id = id.substring(0, idx);
      }
      // �˴������ֵ��ѯ�滻���е�label
      String mappedId = htDict.get(id);
      if (mappedId != null) {
        t.setIdentifier(mappedId);
      } else {
        t.setIdentifier(id);
      }
    }

    return reduced;
  }
예제 #15
0
    // maps the public ID to an alternate URI, if one is registered
    private String name2uri(String publicId) {

      if (publicId == null || id2uri == null) return null;
      return (String) id2uri.get(publicId);
    }
예제 #16
0
 public void registerCatalogEntry(String publicId, String uri) {
   if (id2uri == null) id2uri = new Hashtable(17);
   id2uri.put(publicId, uri);
 }