コード例 #1
0
  public void addExceptions(java.lang.String exceptionStr) {
    if (Configuration.getShowImport().equalsIgnoreCase("true")) {
      java.lang.String simplename = "";
      java.lang.String fullName = exceptionStr;
      int lastSlash = fullName.lastIndexOf("/");
      if (lastSlash == -1) {
        lastSlash = fullName.lastIndexOf(".");
      }
      if (lastSlash != -1) {
        simplename = fullName.substring(lastSlash + 1);
      } else simplename = fullName;
      fullName = fullName.replace('/', '.');
      ConsoleLauncher.addImportClass(fullName);
      exceptions.add(simplename);

    } else exceptions.add(exceptionStr);
  }
コード例 #2
0
ファイル: Type.java プロジェクト: nypgit/alto
 /**
  * Single pass scan for fext delimiter with safety check with respect to string ordering of path
  * delimiters.
  */
 public static final int IndexOfFext(java.lang.String path) {
   if (null == path) return -1;
   else {
     if (java.io.File.pathSeparatorChar != '/') {
       path = path.replace(java.io.File.pathSeparatorChar, '/');
     }
     char[] cary = path.toCharArray();
     for (int cc = (cary.length - 1); -1 < cc; cc--) {
       switch (cary[cc]) {
         case '/':
           return -1;
         case '.':
           return cc;
         default:
           break;
       }
     }
     return -1;
   }
 }
コード例 #3
0
  public void parseDescriptor(java.lang.String descriptor) {
    if (methodName.equalsIgnoreCase("<clinit>")) {
      methodName = "static";
      descriptor = "";
      accessSpecifiers = new java.lang.String[] {""};
      return;
    }
    int charIndex = 0;
    java.lang.String parameterString = descriptor.substring(1, descriptor.lastIndexOf(")"));
    java.lang.String returnString = descriptor.substring(descriptor.lastIndexOf(")") + 1);
    if (returnString.trim().charAt(0) == 'L' || returnString.trim().charAt(0) == '[')
      this.setReturnTypeAsObjectOrArrayType(true);
    else this.setReturnTypeAsObjectOrArrayType(false);

    java.lang.String arrString = "";
    // while(charIndex < parameterString.length())
    while (parameterString.length() > 0) {
      if (parameterString.startsWith("L")) {
        java.lang.String objectString = parameterString.substring(0, parameterString.indexOf(";"));
        objectString = objectString.replace('/', '.');
        parameters.add(objectString);
        charIndex = charIndex + (objectString.length() + 2);
        parameterString = parameterString.substring(parameterString.indexOf(";") + 1);
      } else {
        char parameterChar = parameterString.charAt(0);
        if (parameterChar == '[') {
          arrString = "";
          while (parameterString.startsWith("[")) {
            arrString += "[";
            parameterString = parameterString.substring(1, parameterString.length());
            isParameterArray = true;
          }
          java.lang.String objectString = "";
          if (parameterString.charAt(0) == 'L') {
            objectString = parameterString.substring(0, parameterString.indexOf(";"));
            parameterString = parameterString.substring(parameterString.indexOf(";") + 1);
            objectString = objectString.replace('/', '.');
            parameters.add(arrString + objectString);
            isParameterArray = false;
          }
          /*
           * while(objectString.startsWith("[")) { arrString += "[";
           * objectString =
           * objectString.substring(1,objectString.length()); }
           * objectString = objectString.substring(1); objectString =
           * objectString.replace('/','.');
           * parameters.add(objectString); charIndex = charIndex +
           * (objectString.length() + 2);
           * parameters.add(arrString+objectString);
           */

        } else {
          if (parameterChar == 'I') {
            if (isParameterArray) {
              parameters.add(arrString + "int");
              isParameterArray = false;
            } else {
              parameters.add("int");
            }
          }
          if (parameterChar == 'B') {
            if (isParameterArray) {
              parameters.add(arrString + "byte");
              isParameterArray = false;
            } else {
              parameters.add("byte");
            }
          }
          if (parameterChar == 'C') {
            if (isParameterArray) {
              parameters.add(arrString + "char");
              isParameterArray = false;
            } else {
              parameters.add("char");
            }
          }
          if (parameterChar == 'D') {
            if (isParameterArray) {
              parameters.add(arrString + "double");
              isParameterArray = false;
            } else {
              parameters.add("double");
            }
          }
          if (parameterChar == 'F') {
            if (isParameterArray) {
              parameters.add(arrString + "float");
              isParameterArray = false;
            } else {
              parameters.add("float");
            }
          }
          if (parameterChar == 'J') {
            if (isParameterArray) {
              parameters.add(arrString + "long");
              isParameterArray = false;
            } else {
              parameters.add("long");
            }
          }
          if (parameterChar == 'S') {
            if (isParameterArray) {
              parameters.add(arrString + "short");
              isParameterArray = false;
            } else {
              parameters.add("short");
            }
          }
          if (parameterChar == 'Z') {
            if (isParameterArray) {
              parameters.add(arrString + "boolean");
              isParameterArray = false;
            } else {
              parameters.add("boolean");
            }
          }
          parameterString = parameterString.substring(1);
        }
      }
    }

    if (returnString.indexOf(";") != -1) {
      returnString = returnString.substring(0, returnString.indexOf(";"));
    }

    while (returnString.length() > 0) {
      // System.out.println();
      if (returnString.startsWith("L")) {
        // System.out.println(returnString + " "+returnType.length());
        returnType = returnString.substring(1, returnString.length());
        returnType = returnType.replace('/', '.');
        returnString = "";
      } else {
        if (returnString.equals("I")) {
          returnType = "int";
          returnString = "";
        }
        if (returnString.equals("B")) {
          returnType = "byte";
          returnString = "";
        }
        if (returnString.equals("C")) {
          returnType = "char";
          returnString = "";
        }
        if (returnString.equals("D")) {
          returnType = "double";
          returnString = "";
        }
        if (returnString.equals("F")) {
          returnType = "float";
          returnString = "";
        }
        if (returnString.equals("J")) {
          returnType = "long";
          returnString = "";
        }
        if (returnString.equals("S")) {
          returnType = "short";
          returnString = "";
        }
        if (returnString.equals("Z")) {
          returnType = "boolean";
          returnString = "";
        }
        if (returnString.equals("V")) {
          returnType = "void";
          returnString = "";
        }
        if (returnString.startsWith("[")) {
          returnTypeIsArray = true;
          returnTypeArrayDimension = returnString.lastIndexOf("[") + 1;
          if (returnString.indexOf("L") != -1) {
            returnType = returnString.substring(returnString.lastIndexOf("[") + 2);
            returnType = returnType.replace('/', '.');
            returnString = "";
            // returnString =returnType;
          } else {
            returnString = returnString.substring(returnString.lastIndexOf("[") + 1);
            // returnString = "";

          }
        }
      }
    }
  }
コード例 #4
0
ファイル: ScpSink.java プロジェクト: UoM-ResPlat-DevOps/daris
  @Override
  public void consume(
      java.lang.Object multiCtx,
      java.lang.String path,
      java.util.Map<java.lang.String, java.lang.String> parameters,
      XmlDoc.Element userMeta,
      XmlDoc.Element meta,
      LongInputStream in,
      java.lang.String appMimeType,
      java.lang.String streamMimeType,
      long length)
      throws Throwable {

    Connection conn = multiCtx == null ? null : ((MultiTransferContext) multiCtx).connection;
    Session session = multiCtx == null ? null : ((MultiTransferContext) multiCtx).session;
    Params params = Params.parse(parameters);
    if (multiCtx == null) {
      conn = Ssh.get().getConnection(params.serverDetails());
      session = conn.connect(params.userDetails(), true);
    }

    String assetId = meta != null ? meta.value("@id") : null;
    String ext = meta != null ? meta.value("content/type/@ext") : null;

    try {

      String baseDir = params.directory != null ? params.directory : session.getHome();
      StringBuilder sb = new StringBuilder(baseDir);
      if (!baseDir.endsWith("/")) {
        sb.append("/");
      }
      if (path != null) {
        path = path.replace("\\\\", "/").replace("\\", "/");
        while (path.startsWith("/")) {
          path = path.substring(1);
        }
        sb.append(path);
      }

      Set<String> existingDirs =
          multiCtx == null
              ? Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>())
              : ((MultiTransferContext) multiCtx).existingDirectories;
      if (params.decompress
          && streamMimeType != null
          && ArchiveRegistry.isAnArchive(streamMimeType)) {
        // decompress archive
        if (assetId != null) {
          sb.append("/");
          sb.append("asset_");
          sb.append(assetId);
        }
        if (RemoteArchiveExtractor.canExtract(session, streamMimeType)) {
          sb.append("/");
          sb.append(PathUtil.getRandomFileName(8));
          sb.append(".tmp");
          String remotePath = sb.toString();
          transfer(session, in, length, remotePath, params.fileMode, existingDirs);
          RemoteArchiveExtractor.extract(session, remotePath);
        } else {
          extractAndTransfer(
              session,
              sb.toString(),
              ArchiveRegistry.createInput(in, new NamedMimeType(streamMimeType)),
              params.fileMode,
              existingDirs);
        }
      } else {
        // single file
        if (assetId != null) {
          sb.append("/");
          sb.append("asset_");
          sb.append(assetId);
        }
        if (ext != null) {
          sb.append(".");
          sb.append(ext);
        }
        transfer(session, in, length, sb.toString(), params.fileMode, existingDirs);
      }
    } finally {
      if (multiCtx == null) {
        if (session != null) {
          session.close();
        }
        if (conn != null) {
          conn.disconnect();
        }
      }
    }
  }