Exemplo n.º 1
0
  @Override
  public String normalize(String path) {
    char separatorChar = SystemProperties.getProperty("file.separator").charAt(0);
    int dupIndex = path.indexOf(dupSeparator);
    int plen = path.length();

    if (dupIndex == -1) {
      // Ignore trailing separator (though on Windows "a:\", for
      // example, is a valid and minimal path).
      if (plen > 1 && path.charAt(plen - 1) == separatorChar) {
        if (!(separatorChar == '\\' && plen == 3 && path.charAt(1) == ':'))
          return path.substring(0, plen - 1);
      } else return path;
    }

    StringBuffer newpath = new StringBuffer(plen);
    int last = 0;
    while (dupIndex != -1) {
      newpath.append(path.substring(last, dupIndex));
      // Ignore the duplicate path characters.
      while (path.charAt(dupIndex) == separatorChar) {
        dupIndex++;
        if (dupIndex == plen) return newpath.toString();
      }
      newpath.append(separatorChar);
      last = dupIndex;
      dupIndex = path.indexOf(dupSeparator, last);
    }

    newpath.append(path.substring(last, plen));

    return newpath.toString();
  }
 /**
  * Chooses, instantiates and returns a service provider.
  *
  * @return a service provider
  */
 private static RMIClassLoaderSpi getProviderInstance() {
   // If the user asked for the default, return it.  We do a special
   // check here because our standard service lookup function does not
   // handle this -- nor should it.
   String prop = SystemProperties.getProperty("java.rmi.server.RMIClassLoaderSpi");
   if ("default".equals(prop)) return null;
   Iterator it = ServiceFactory.lookupProviders(RMIClassLoaderSpi.class, null);
   if (it == null || !it.hasNext()) return null;
   // FIXME: the spec says we ought to throw an Error of some kind if
   // the specified provider is not suitable for some reason.  However
   // our service factory simply logs the problem and moves on to the next
   // provider in this situation.
   return (RMIClassLoaderSpi) it.next();
 }
Exemplo n.º 3
0
 static {
   String separator = SystemProperties.getProperty("file.separator");
   dupSeparator = separator + separator;
 }
Exemplo n.º 4
0
 @Override
 public char getSeparator() {
   return SystemProperties.getProperty("file.separator").charAt(0);
 }