Пример #1
0
  /**
   * Get the set of properties that match a specified pattern. The match pattern accepts a single
   * '*' char anywhere in the pattern. If the '*' is placed somewhere in the middle of the pattern,
   * then then the subset will contain properties that startWith everything before the '*' and end
   * with everything after the '*'.
   *
   * <p>Sample property patterns:
   *
   * <table>
   * <tr><td>*.bar<td>   returns the subset of properties that end with '.bar'
   * <tr><td>bar.*<td>   returns the subset of properties that begin with 'bar.'
   * <tr><td>foo*bar<td> returns the subset of properties that begin with 'foo' and end with 'bar'
   * </table>
   *
   * @param propPattern a pattern with 0 or 1 '*' chars.
   * @return the subset of properties that match the specified pattern. Note that changing the
   *     properties in the returned subset will not affect this object.
   */
  public Properties getProperties(String propPattern) {
    Properties props = new Properties();
    int index = propPattern.indexOf("*");
    if (index == -1) {
      String value = getProperty(propPattern);
      if (value != null) {
        props.put(propPattern, value);
      }
    } else {
      String startsWith = propPattern.substring(0, index);
      String endsWith;
      if (index == propPattern.length() - 1) {
        endsWith = null;
      } else {
        endsWith = propPattern.substring(index + 1);
      }

      Enumeration names = propertyNames();
      while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        if (name.startsWith(startsWith)) {
          if (endsWith == null) {
            props.put(name, getProperty(name));
          } else if (name.endsWith(endsWith)) {
            props.put(name, getProperty(name));
          }
        }
      }
    }
    return props;
  }
Пример #2
0
  protected PermissionCollection getPermissions(CodeSource codeSource) {
    PermissionCollection perms;
    try {
      try {
        perms = super.getPermissions(codeSource);
      } catch (SecurityException e) {
        // We lied about our CodeSource and that makes URLClassLoader unhappy.
        perms = new Permissions();
      }

      ProtectionDomain myDomain =
          AccessController.doPrivileged(
              new PrivilegedAction<ProtectionDomain>() {
                public ProtectionDomain run() {
                  return getClass().getProtectionDomain();
                }
              });
      PermissionCollection myPerms = myDomain.getPermissions();
      if (myPerms != null) {
        for (Enumeration<Permission> elements = myPerms.elements(); elements.hasMoreElements(); ) {
          perms.add(elements.nextElement());
        }
      }
    } catch (Throwable e) {
      // We lied about our CodeSource and that makes URLClassLoader unhappy.
      perms = new Permissions();
    }
    perms.setReadOnly();
    return perms;
  }
Пример #3
0
 /** @see java.lang.ClassLoader#findResources(java.lang.String) */
 @Override
 public Enumeration<URL> findResources(String resourceName) throws IOException {
   String webInfResourceName = "WEB-INF/classes/" + resourceName;
   List<URL> urlList = new ArrayList<URL>();
   int jarFileListSize = jarFileList.size();
   for (int i = 0; i < jarFileListSize; i++) {
     JarFile jarFile = jarFileList.get(i);
     JarEntry jarEntry = jarFile.getJarEntry(resourceName);
     // to better support war format, look for the resourceName in the WEB-INF/classes directory
     if (loadWebInf && jarEntry == null) jarEntry = jarFile.getJarEntry(webInfResourceName);
     if (jarEntry != null) {
       try {
         String jarFileName = jarFile.getName();
         if (jarFileName.contains("\\")) jarFileName = jarFileName.replace('\\', '/');
         urlList.add(new URL("jar:file:" + jarFileName + "!/" + jarEntry));
       } catch (MalformedURLException e) {
         System.out.println(
             "Error making URL for ["
                 + resourceName
                 + "] in jar ["
                 + jarFile
                 + "] in war file ["
                 + outerFile
                 + "]: "
                 + e.toString());
       }
     }
   }
   // add all resources found in parent loader too
   Enumeration<URL> superResources = super.findResources(resourceName);
   while (superResources.hasMoreElements()) urlList.add(superResources.nextElement());
   return Collections.enumeration(urlList);
 }
Пример #4
0
  /**
   * Returns a Set of Strings containing the names of all available algorithms or types for the
   * specified Java cryptographic service (e.g., Signature, MessageDigest, Cipher, Mac, KeyStore).
   * Returns an empty Set if there is no provider that supports the specified service or if
   * serviceName is null. For a complete list of Java cryptographic services, please see the <a
   * href="../../../guide/security/CryptoSpec.html">Java Cryptography Architecture API Specification
   * &amp; Reference</a>. Note: the returned set is immutable.
   *
   * @param serviceName the name of the Java cryptographic service (e.g., Signature, MessageDigest,
   *     Cipher, Mac, KeyStore). Note: this parameter is case-insensitive.
   * @return a Set of Strings containing the names of all available algorithms or types for the
   *     specified Java cryptographic service or an empty set if no provider supports the specified
   *     service.
   * @since 1.4
   */
  public static Set<String> getAlgorithms(String serviceName) {

    if ((serviceName == null) || (serviceName.length() == 0) || (serviceName.endsWith("."))) {
      return Collections.EMPTY_SET;
    }

    HashSet result = new HashSet();
    Provider[] providers = Security.getProviders();

    for (int i = 0; i < providers.length; i++) {
      // Check the keys for each provider.
      for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) {
        String currentKey = ((String) e.nextElement()).toUpperCase();
        if (currentKey.startsWith(serviceName.toUpperCase())) {
          // We should skip the currentKey if it contains a
          // whitespace. The reason is: such an entry in the
          // provider property contains attributes for the
          // implementation of an algorithm. We are only interested
          // in entries which lead to the implementation
          // classes.
          if (currentKey.indexOf(" ") < 0) {
            result.add(currentKey.substring(serviceName.length() + 1));
          }
        }
      }
    }
    return Collections.unmodifiableSet(result);
  }
Пример #5
0
  protected void unpackComponents() throws IOException, FileNotFoundException {
    File applicationPackage = new File(getApplication().getPackageResourcePath());
    File componentsDir = new File(sGREDir, "components");
    if (componentsDir.lastModified() == applicationPackage.lastModified()) return;

    componentsDir.mkdir();
    componentsDir.setLastModified(applicationPackage.lastModified());

    GeckoAppShell.killAnyZombies();

    ZipFile zip = new ZipFile(applicationPackage);

    byte[] buf = new byte[32768];
    try {
      if (unpackFile(zip, buf, null, "removed-files")) removeFiles();
    } catch (Exception ex) {
      // This file may not be there, so just log any errors and move on
      Log.w(LOG_FILE_NAME, "error removing files", ex);
    }

    // copy any .xpi file into an extensions/ directory
    Enumeration<? extends ZipEntry> zipEntries = zip.entries();
    while (zipEntries.hasMoreElements()) {
      ZipEntry entry = zipEntries.nextElement();
      if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) {
        Log.i("GeckoAppJava", "installing extension : " + entry.getName());
        unpackFile(zip, buf, entry, entry.getName());
      }
    }
  }
Пример #6
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    Enumeration values = req.getParameterNames();
    String name = "";
    String value = "";
    String id = "";
    while (values.hasMoreElements()) {
      name = ((String) values.nextElement()).trim();
      value = req.getParameter(name).trim();
      if (name.equals("id")) id = value;
    }
    if (url.equals("")) {
      url = getServletContext().getInitParameter("url");
      cas_url = getServletContext().getInitParameter("cas_url");
    }
    HttpSession session = null;
    session = req.getSession(false);
    if (session != null) {
      session.invalidate();
    }
    res.sendRedirect(cas_url);
    return;
  }
  /** Opens the Serial port with the baud and port_name given */
  public boolean OpenSerial(int baud, String port) {
    CommPortIdentifier portId = null;
    Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

    while (portEnum.hasMoreElements()) {
      CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
      if (currPortId.getName().equals(port)) {
        portId = currPortId;
        break;
      }
    }

    if (portId == null) {
      System.err.println("Can not open serial port");
      return false;
    }

    try {
      serialPort = (SerialPort) portId.open(this.getClass().getName(), 2000);

      serialPort.setSerialPortParams(
          baud, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

      input = serialPort.getInputStream();
      output = serialPort.getOutputStream();

      serialPort.addEventListener(this);
      serialPort.notifyOnDataAvailable(true);
      Thread.sleep(1500);
    } catch (Exception e) {
      return false;
    }

    return true;
  }
Пример #8
0
  //
  // f0 -> "try"
  // f1 -> Block()
  // f2 -> ( "catch" "(" FormalParameter() ")" Block() )*
  // f3 -> [ "finally" Block() ]
  //
  public void visit(TryStatement n) {
    out.println(n.f0);
    out.print(spc.spc);
    n.f1.accept(this);
    for (Enumeration e = n.f2.elements(); e.hasMoreElements(); ) {
      NodeSequence seq = (NodeSequence) e.nextElement();
      out.println();
      out.print(spc.spc);
      seq.elementAt(0).accept(this);
      out.print(" ");
      seq.elementAt(1).accept(this);
      seq.elementAt(2).accept(this);
      seq.elementAt(3).accept(this);
      out.println();
      out.print(spc.spc);
      seq.elementAt(4).accept(this);
    }

    if (n.f3.present()) {
      NodeSequence seq = (NodeSequence) n.f3.node;
      out.println();
      seq.elementAt(0).accept(this);
      out.println();
      out.print(spc.spc);
      seq.elementAt(1).accept(this);
    }
  }
Пример #9
0
 public void visit(NodeListOptional n, String sep) {
   if (n.present())
     for (Enumeration e = n.elements(); e.hasMoreElements(); ) {
       ((Node) e.nextElement()).accept(this);
       if (e.hasMoreElements()) out.print(sep);
     }
 }
Пример #10
0
 //
 // f0 -> "switch"
 // f1 -> "("
 // f2 -> Expression()
 // f3 -> ")"
 // f4 -> "{"
 // f5 -> ( SwitchLabel() ( BlockStatement() )* )*
 // f6 -> "}"
 //
 public void visit(SwitchStatement n) {
   out.print(n.f0 + " " + n.f1);
   n.f2.accept(this);
   out.println(n.f3);
   out.println(spc.spc + n.f4);
   spc.updateSpc(+1);
   for (Enumeration e = n.f5.elements(); e.hasMoreElements(); ) {
     NodeSequence seq = (NodeSequence) e.nextElement();
     out.print(spc.spc);
     seq.elementAt(0).accept(this);
     spc.updateSpc(+1);
     if (((NodeListOptional) seq.elementAt(1)).present()) {
       if (((NodeListOptional) seq.elementAt(1)).size() == 1) out.print(" ");
       else {
         out.println();
         out.print(spc.spc);
       }
       visit((NodeListOptional) seq.elementAt(1), "\n" + spc.spc);
     }
     out.println();
     spc.updateSpc(-1);
   }
   spc.updateSpc(-1);
   out.println(spc.spc + n.f6);
 }
Пример #11
0
 //
 // For convenience, trusts that the node passed to it is a NodeSequence.
 // (of course, will throw an exception if it isn't).
 //
 public void visit(Node n1, String sep) {
   NodeSequence n = (NodeSequence) n1;
   for (Enumeration e = n.elements(); e.hasMoreElements(); ) {
     ((Node) e.nextElement()).accept(this);
     if (e.hasMoreElements()) out.print(sep);
   }
 }
Пример #12
0
 /** Utility method to stuff an entire enumeration into a vector */
 public static Vector Enum2Vector(Enumeration e) {
   Vector v = new Vector();
   while (e.hasMoreElements()) {
     v.add(e.nextElement());
   }
   return v;
 }
Пример #13
0
 private void printResponse_() {
   Enumeration e = (serverResponse == null) ? null : serverResponse.elements();
   for (; e != null && e.hasMoreElements(); ) {
     System.out.println(e.nextElement());
   }
   System.out.println("no server response");
 }
Пример #14
0
 /**
  * Add set of properties to this object. This method will replace the value of any properties that
  * already existed.
  */
 public void setProperties(Properties props) {
   Enumeration names = props.propertyNames();
   while (names.hasMoreElements()) {
     String name = (String) names.nextElement();
     setProperty(name, props.getProperty(name));
   }
 }
 private Class<?> findClassInComponents(final String name) throws ClassNotFoundException {
   final String classFilename = this.getClassFilename(name);
   final Enumeration<File> e = this.pathComponents.elements();
   while (e.hasMoreElements()) {
     final File pathComponent = e.nextElement();
     InputStream stream = null;
     try {
       stream = this.getResourceStream(pathComponent, classFilename);
       if (stream != null) {
         this.log("Loaded from " + pathComponent + " " + classFilename, 4);
         return this.getClassFromStream(stream, name, pathComponent);
       }
       continue;
     } catch (SecurityException se) {
       throw se;
     } catch (IOException ioe) {
       this.log(
           "Exception reading component " + pathComponent + " (reason: " + ioe.getMessage() + ")",
           3);
     } finally {
       FileUtils.close(stream);
     }
   }
   throw new ClassNotFoundException(name);
 }
Пример #16
0
    public static void copyJarResourcesRecursively(File destination, JarURLConnection jarConnection) {
        JarFile jarFile;
        try {
            jarFile = jarConnection.getJarFile();
        } catch (Exception e) {
            _.die("Failed to get jar file)");
            return;
        }

        Enumeration<JarEntry> em = jarFile.entries();
        while (em.hasMoreElements()) {
            JarEntry entry = em.nextElement();
            if (entry.getName().startsWith(jarConnection.getEntryName())) {
                String fileName = StringUtils.removeStart(entry.getName(), jarConnection.getEntryName());
                if (!fileName.equals("/")) {  // exclude the directory
                    InputStream entryInputStream = null;
                    try {
                        entryInputStream = jarFile.getInputStream(entry);
                        FileUtils.copyInputStreamToFile(entryInputStream, new File(destination, fileName));
                    } catch (Exception e) {
                        die("Failed to copy resource: " + fileName);
                    } finally {
                        if (entryInputStream != null) {
                            try {
                                entryInputStream.close();
                            } catch (Exception e) {
                            }
                        }
                    }
                }
            }
        }
    }
  /** The main method. */
  public static void main(String[] ops) {

    KEAKeyphraseExtractor kmb = new KEAKeyphraseExtractor();
    try {
      kmb.setOptions(ops);
      System.err.print("Extracting keyphrases with options: ");
      String[] optionSettings = kmb.getOptions();
      for (int i = 0; i < optionSettings.length; i++) {
        System.err.print(optionSettings[i] + " ");
      }
      System.err.println();
      kmb.loadModel();
      kmb.extractKeyphrases(kmb.collectStems());
    } catch (Exception e) {
      e.printStackTrace();
      System.err.println(e.getMessage());
      System.err.println("\nOptions:\n");
      Enumeration enumeration = kmb.listOptions();
      while (enumeration.hasMoreElements()) {
        Option option = (Option) enumeration.nextElement();
        System.err.println(option.synopsis());
        System.err.println(option.description());
      }
    }
  }
Пример #18
0
  /**
   * Loads the keystore from the Keychain.
   *
   * @param stream Ignored - here for API compatibility.
   * @param password Ignored - if user needs to unlock keychain Security framework will post any
   *     dialogs.
   * @exception IOException if there is an I/O or format problem with the keystore data
   * @exception NoSuchAlgorithmException if the algorithm used to check the integrity of the
   *     keystore cannot be found
   * @exception CertificateException if any of the certificates in the keystore could not be loaded
   */
  public void engineLoad(InputStream stream, char[] password)
      throws IOException, NoSuchAlgorithmException, CertificateException {
    permissionCheck();

    // Release any stray keychain references before clearing out the entries.
    synchronized (entries) {
      for (Enumeration<String> e = entries.keys(); e.hasMoreElements(); ) {
        String alias = e.nextElement();
        Object entry = entries.get(alias);
        if (entry instanceof TrustedCertEntry) {
          if (((TrustedCertEntry) entry).certRef != 0) {
            _releaseKeychainItemRef(((TrustedCertEntry) entry).certRef);
          }
        } else {
          KeyEntry keyEntry = (KeyEntry) entry;

          if (keyEntry.chain != null) {
            for (int i = 0; i < keyEntry.chain.length; i++) {
              if (keyEntry.chainRefs[i] != 0) {
                _releaseKeychainItemRef(keyEntry.chainRefs[i]);
              }
            }

            if (keyEntry.keyRef != 0) {
              _releaseKeychainItemRef(keyEntry.keyRef);
            }
          }
        }
      }

      entries.clear();
      _scanKeychain();
    }
  }
Пример #19
0
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String pathInfo = req.getPathInfo();

    if (pathInfo.equals("/")) {
      HttpSession session = req.getSession();
      if (session == null) {
        resp.setStatus(401);
        return;
      }
      String username = (String) session.getAttribute("username");
      if (username == null) {
        resp.setStatus(401);
        return;
      }

      Map userMap = loadUserSettingsMap(username);
      if (userMap == null) {
        resp.setStatus(401);
        return;
      }
      Enumeration parameterNames = req.getParameterNames();
      while (parameterNames.hasMoreElements()) {
        String parameterName = (String) parameterNames.nextElement();
        userMap.put(parameterName, req.getParameter(parameterName));
      }
      saveUserSettingsMap(username, userMap);
      return;
    }

    super.doPost(req, resp);
  }
Пример #20
0
  protected Vector /* of TTPNode */ queryPNodes1(String query) throws IOException {
    write(query);
    Vector lines = readlines();
    Vector r = new Vector();
    for (Enumeration e = lines.elements(); e.hasMoreElements(); ) {
      Vector line = stringToVector((String) e.nextElement(), ":");

      TTLexEntry le = new TTLexEntry();
      le.citationForm = (String) line.elementAt(0);
      le.features = (String) line.elementAt(1);
      le.inflection = (String) line.elementAt(2);
      le.inflFeatures = (String) line.elementAt(3);

      TTLexEntryToObj leo = new TTLexEntryToObj();
      leo.lexentry = le;
      leo.objname = (String) line.elementAt(4);
      leo.features = (String) line.elementAt(5);

      TTPNode pn = new TTPNode();
      pn.feature = TT.featureGet(le.features, TT.FT_POS, TT.F_NULL);
      pn.leo = leo;
      pn.startpos = TT.longParse((String) line.elementAt(8), true);
      pn.endpos = TT.longParse((String) line.elementAt(9), true);

      r.addElement(pn);
    }
    return r;
  }
Пример #21
0
  /**
   * Looks up providers, and returns the property (and its associated provider) mapping the key, if
   * any. The order in which the providers are looked up is the provider-preference order, as
   * specificed in the security properties file.
   */
  private static ProviderProperty getProviderProperty(String key) {
    ProviderProperty entry = null;

    List providers = Providers.getProviderList().providers();
    for (int i = 0; i < providers.size(); i++) {

      String matchKey = null;
      Provider prov = (Provider) providers.get(i);
      String prop = prov.getProperty(key);

      if (prop == null) {
        // Is there a match if we do a case-insensitive property name
        // comparison? Let's try ...
        for (Enumeration e = prov.keys(); e.hasMoreElements() && prop == null; ) {
          matchKey = (String) e.nextElement();
          if (key.equalsIgnoreCase(matchKey)) {
            prop = prov.getProperty(matchKey);
            break;
          }
        }
      }

      if (prop != null) {
        ProviderProperty newEntry = new ProviderProperty();
        newEntry.className = prop;
        newEntry.provider = prov;
        return newEntry;
      }
    }

    return entry;
  }
Пример #22
0
  /** @param aProperties the updated properties. */
  @SuppressWarnings("rawtypes")
  final void setProperties(final Dictionary aProperties) {
    final Map<String, String> newProps = new HashMap<String, String>();

    Enumeration keys = aProperties.keys();
    while (keys.hasMoreElements()) {
      final String key = (String) keys.nextElement();
      if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) {
        LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key);
        continue;
      }

      final String value = aProperties.get(key).toString();
      newProps.put(key, value.trim());
    }

    // Verify whether all known keys are defined...
    final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS);
    checkedKeys.removeAll(newProps.keySet());
    if (!checkedKeys.isEmpty()) {
      throw new IllegalArgumentException(
          "Profile settings not complete! Missing keys are: " + checkedKeys.toString());
    }

    this.properties.putAll(newProps);

    LOG.log(
        Level.INFO,
        "New device profile settings applied for {1} ({0}) ...", //
        new Object[] {getType(), getDescription()});
  }
Пример #23
0
  /**
   * Processes a packet read from either the multicast or unicast socket. Needs to be synchronized
   * because mcast or unicast socket reads can be concurrent
   */
  void handleIncomingUdpPacket(byte[] data) {
    ByteArrayInputStream inp_stream;
    ObjectInputStream inp;
    Message msg = null;
    List l; // used if bundling is enabled

    try {
      // skip the first n bytes (default: 4), this is the version info
      inp_stream = new ByteArrayInputStream(data, VERSION_LENGTH, data.length - VERSION_LENGTH);
      inp = new ObjectInputStream(inp_stream);
      if (enable_bundling) {
        l = new List();
        l.readExternal(inp);
        for (Enumeration en = l.elements(); en.hasMoreElements(); ) {
          msg = (Message) en.nextElement();
          try {
            handleMessage(msg);
          } catch (Throwable t) {
            Trace.error("UDP.handleIncomingUdpPacket()", "failure: " + t.toString());
          }
        }
      } else {
        msg = new Message();
        msg.readExternal(inp);
        handleMessage(msg);
      }
    } catch (Throwable e) {
      Trace.error("UDP.handleIncomingUdpPacket()", "exception=" + Trace.getStackTrace(e));
    }
  }
Пример #24
0
 /** Sets Tesseract's internal parameters. */
 private void setTessVariables() {
   Enumeration<?> em = prop.propertyNames();
   while (em.hasMoreElements()) {
     String key = (String) em.nextElement();
     api.TessBaseAPISetVariable(handle, key, prop.getProperty(key));
   }
 }
  public static Map<String, String> readProperties(InputStream inputStream) {
    Map<String, String> propertiesMap = null;
    try {
      propertiesMap = new LinkedHashMap<String, String>();

      Properties properties = new Properties();
      properties.load(inputStream);

      Enumeration<?> enumeration = properties.propertyNames();
      while (enumeration.hasMoreElements()) {
        String key = (String) enumeration.nextElement();
        String value = (String) properties.get(key);
        propertiesMap.put(key, value);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    return propertiesMap;
  }
Пример #26
0
 private void printResults() {
   for (Enumeration e = table.keys(); e.hasMoreElements(); ) {
     String instr = (String) e.nextElement();
     Integer count = (Integer) table.get(instr);
     System.out.println(instr + "\t" + count);
   }
 }
Пример #27
0
  public MoquiStart(ClassLoader parent, boolean loadWebInf) {
    super(parent);
    this.loadWebInf = loadWebInf;

    URL wrapperWarUrl = null;
    try {
      // get outer file (the war file)
      pd = getClass().getProtectionDomain();
      CodeSource cs = pd.getCodeSource();
      wrapperWarUrl = cs.getLocation();
      outerFile = new JarFile(new File(wrapperWarUrl.toURI()));

      // allow for classes in the outerFile as well
      jarFileList.add(outerFile);

      Enumeration<JarEntry> jarEntries = outerFile.entries();
      while (jarEntries.hasMoreElements()) {
        JarEntry je = jarEntries.nextElement();
        if (je.isDirectory()) continue;
        // if we aren't loading the WEB-INF files and it is one, skip it
        if (!loadWebInf && je.getName().startsWith("WEB-INF")) continue;
        // get jars, can be anywhere in the file
        String jeName = je.getName().toLowerCase();
        if (jeName.lastIndexOf(".jar") == jeName.length() - 4) {
          File file = createTempFile(je);
          jarFileList.add(new JarFile(file));
        }
      }
    } catch (Exception e) {
      System.out.println("Error loading jars in war file [" + wrapperWarUrl + "]: " + e.toString());
    }
  }
 public URL getResource(final String name) {
   URL url = null;
   if (this.isParentFirst(name)) {
     url = ((this.parent == null) ? super.getResource(name) : this.parent.getResource(name));
   }
   if (url != null) {
     this.log("Resource " + name + " loaded from parent loader", 4);
   } else {
     final Enumeration<File> e = this.pathComponents.elements();
     while (e.hasMoreElements() && url == null) {
       final File pathComponent = e.nextElement();
       url = this.getResourceURL(pathComponent, name);
       if (url != null) {
         this.log("Resource " + name + " loaded from ant loader", 4);
       }
     }
   }
   if (url == null && !this.isParentFirst(name)) {
     if (this.ignoreBase) {
       url = ((this.getRootLoader() == null) ? null : this.getRootLoader().getResource(name));
     } else {
       url = ((this.parent == null) ? super.getResource(name) : this.parent.getResource(name));
     }
     if (url != null) {
       this.log("Resource " + name + " loaded from parent loader", 4);
     }
   }
   if (url == null) {
     this.log("Couldn't load Resource " + name, 4);
   }
   return url;
 }
 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);
 }
Пример #30
0
 // Recursively compute size of the dds to be returned
 private long computeSize(DConstructor ctor, boolean isAscii) throws Exception {
   long projectsize = 0; // accumulate size of projected variables
   long othersize = 0; // accumulate size of non-projected variables
   long fieldsize = 0;
   int projectedcount = 0;
   int fieldcount = 0;
   Enumeration vars = ctor.getVariables();
   while (vars.hasMoreElements()) {
     fieldcount++;
     BaseType field = (BaseType) vars.nextElement();
     fieldsize = computeFieldSize(field, isAscii);
     // accumulate the field sizes
     if (field.isProject()) {
       projectsize += fieldsize;
       projectedcount++;
     } else {
       othersize += fieldsize;
     }
   }
   // Cases to consider:
   // 1. If all of the fields of this ctor are projected,
   //    then return projectsize
   // 2. If none of the fields of this ctor are projected,
   //    then return othersize
   // 3. otherwise, at least one field, but not all, is projected,
   //    => return projectsize;
   if (projectedcount == fieldcount) return projectsize;
   else if (projectedcount == 0) return othersize;
   else {
     assert (projectedcount > 0 && projectedcount < fieldcount);
     return projectsize;
   }
 }