@Test public void testEscape() { Archive a = Archive.TAR; assertEquals("file\\ name", a.escape("file name")); assertEquals("file\\(name", a.escape("file(name")); assertEquals("\\$filename", a.escape("$filename")); }
protected String escape(final String path) { final StringBuilder escaped = new StringBuilder(); for(char c : path.toCharArray()) { if(StringUtils.isAlphanumeric(String.valueOf(c)) || c == Path.DELIMITER) { escaped.append(c); } else { escaped.append("\\").append(c); } } return escaped.toString(); }
Archive { protected String escape(final String path) { final StringBuilder escaped = new StringBuilder(); for(char c : path.toCharArray()) { if(StringUtils.isAlphanumeric(String.valueOf(c)) || c == Path.DELIMITER) { escaped.append(c); } else { escaped.append("\\").append(c); } } return escaped.toString(); } }
Archive { protected String escape(final String path) { final StringBuilder escaped = new StringBuilder(); for(char c : path.toCharArray()) { if(StringUtils.isAlphanumeric(String.valueOf(c)) || c == Path.DELIMITER) { escaped.append(c); } else { escaped.append("\\").append(c); } } return escaped.toString(); } private  Archive(final String extension); }
Archive { protected String escape(final String path) { final StringBuilder escaped = new StringBuilder(); for(char c : path.toCharArray()) { if(StringUtils.isAlphanumeric(String.valueOf(c)) || c == Path.DELIMITER) { escaped.append(c); } else { escaped.append("\\").append(c); } } return escaped.toString(); } private  Archive(final String extension); static Archive getDefault(); static Archive[] getKnownArchives(); static Archive forName(final String name); String[] getExtensions(); String getIdentifier(); abstract String getDescription(); Path getArchive(final List<Path> files); List<Path> getExpanded(final List<Path> files); String getTitle(final List<Path> files); String getCompressCommand(final Path workdir, final List<Path> files); String getDecompressCommand(final Path path); static boolean isArchive(final String filename); }
Archive { protected String escape(final String path) { final StringBuilder escaped = new StringBuilder(); for(char c : path.toCharArray()) { if(StringUtils.isAlphanumeric(String.valueOf(c)) || c == Path.DELIMITER) { escaped.append(c); } else { escaped.append("\\").append(c); } } return escaped.toString(); } private  Archive(final String extension); static Archive getDefault(); static Archive[] getKnownArchives(); static Archive forName(final String name); String[] getExtensions(); String getIdentifier(); abstract String getDescription(); Path getArchive(final List<Path> files); List<Path> getExpanded(final List<Path> files); String getTitle(final List<Path> files); String getCompressCommand(final Path workdir, final List<Path> files); String getDecompressCommand(final Path path); static boolean isArchive(final String filename); static final Archive TAR; static final Archive TARGZ; static final Archive TARBZ2; static final Archive ZIP; static final Archive GZIP; static final Archive BZ2; }