public CAttrValue(String strAttrib, String strValue) { m_strAttrib = strAttrib; m_strValue = strValue; if ( m_strAttrib.endsWith("-rhoblob") ) { m_strBlobSuffix = "-rhoblob"; m_strAttrib = m_strAttrib.substring(0,m_strAttrib.length()-m_strBlobSuffix.length()); } }
/** * Canonicalize the path, i.e. remove ".." and "." occurences. * * @param path the path to be canonicalized * @return the canonicalized path */ public static String canonicalizePath(String path) { int dirIndex; while ((dirIndex = path.indexOf("/./")) >= 0) { //$NON-NLS-1$ path = path.substring(0, dirIndex + 1) + path.substring(dirIndex + 3); } if (path.endsWith("/.")) { //$NON-NLS-1$ path = path.substring(0, path.length() - 1); } while ((dirIndex = path.indexOf("/../")) >= 0) { //$NON-NLS-1$ if (dirIndex != 0) { path = path.substring(0, path .lastIndexOf('/', dirIndex - 1)) + path.substring(dirIndex + 3); } else { path = path.substring(dirIndex + 3); } } if (path.endsWith("/..") && path.length() > 3) { //$NON-NLS-1$ path = path.substring(0, path.lastIndexOf('/', path.length() - 4) + 1); } return path; }
private void validateName(String name) { if (name.endsWith("/") && name.length() > 1) { //$NON-NLS-1$ // prefs.6=Name cannot end with '/' throw new java.lang.IllegalArgumentException("Name cannot end with '/'"); //$NON-NLS-1$ } if (name.indexOf("//") >= 0) { //$NON-NLS-1$ // prefs.7=Name cannot contains consecutive '/' throw new java.lang.IllegalArgumentException("Name cannot contains consecutive '/'"); //$NON-NLS-1$ } }
private void init(String path, String pathActions) { if (pathActions == null || pathActions.equals("")) { //$NON-NLS-1$ throw new java.lang.IllegalArgumentException("actions invalid"); //$NON-NLS-1$ } this.actions = toCanonicalActionString(pathActions); if (path == null) { throw new java.lang.NullPointerException("path is null"); //$NON-NLS-1$ } if (path.equals("<<ALL FILES>>")) { //$NON-NLS-1$ includeAll = true; } else { /*canonPath = AccessController .doPrivileged(new PrivilegedAction<String>() { public String run() {*/ try { canonPath = new File(path).getCanonicalPath(); } catch (IOException e) { canonPath = path; }/* } });*/ if (path.equals("*") || path.endsWith(File.separator + "*")) { //$NON-NLS-1$ //$NON-NLS-2$ allDir = true; } if (path.equals("-") || path.endsWith(File.separator + "-")) { //$NON-NLS-1$ //$NON-NLS-2$ allSubdir = true; } } }
public static LexicalizedParser loadModelFromZip(String zipFilename, String modelName) { LexicalizedParser parser = null; try { File file = new File(zipFilename); if (file.exists()) { ZipFile zin = new ZipFile(file); ZipEntry zentry = zin.getEntry(modelName); if (zentry != null) { InputStream in = zin.getInputStream(zentry); // gunzip it if necessary if (modelName.endsWith(".gz")) { in = new GZIPInputStream(in); } ObjectInputStream ois = new ObjectInputStream(in); parser = loadModel(ois); ois.close(); in.close(); } zin.close(); } else { throw new FileNotFoundException("Could not find " + modelName + " inside " + zipFilename); } } catch (IOException e) {