From 53c043ac18ca8dd9d7f823bf7a399058c305003d Mon Sep 17 00:00:00 2001 From: adrianocrestani Date: Mon, 17 Aug 2009 06:24:15 +0000 Subject: committing domain-search changes from patch tuscany_2552_phillipe_ramalho_08_16_2009.patch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804871 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/domain/search/impl/WrappedFileContent.java | 159 +++++++++++---------- 1 file changed, 80 insertions(+), 79 deletions(-) (limited to 'branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/WrappedFileContent.java') diff --git a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/WrappedFileContent.java b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/WrappedFileContent.java index bfb348550f..0a1dfa75e9 100644 --- a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/WrappedFileContent.java +++ b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/WrappedFileContent.java @@ -30,84 +30,85 @@ import java.net.URL; */ public class WrappedFileContent implements FileContent { - final private FileContent fileContent; - - public WrappedFileContent(URL url) throws IOException { - String protocol = url.getProtocol(); - - if (protocol.equals("jar")) { - JarURLConnection jarConn = (JarURLConnection) url.openConnection(); - //Enumeration entries = jarConn.getJarFile().entries(); - String file = url.getFile(); - file = file.substring(file.lastIndexOf('!') + 1); - -// if (file.charAt(file.length() - 1) != '/') { -// -// int beginIndex; -// -// if (file.charAt(0) == '/') { -// beginIndex = 1; -// -// } else { -// beginIndex = 0; -// } -// -// file = file.substring(beginIndex); -// -// while (entries.hasMoreElements()) { -// String actualFile = entries.nextElement().getName(); -// -// if (actualFile.charAt(0) == '/') { -// beginIndex = 1; -// -// } else { -// beginIndex = 0; -// } -// -// if (actualFile.length() - beginIndex == file.length() + 1 && actualFile.charAt(actualFile.length() - 1) == '/') { -// -// if (actualFile.startsWith(file, beginIndex)) { -// file = actualFile; -// -// break; -// -// } -// -// } -// -// } -// -// } - - this.fileContent = ZipFileContent.createZipFileContent(jarConn.getJarFile(), file); - - } else if (protocol.equals("file")) { - this.fileContent = new SystemFileContent(new File(url.getFile())); - - } else { - this.fileContent = new DefaultFileContent(url); - } - - } - - public FileContent[] getChildren() { - return this.fileContent.getChildren(); - } - - public InputStream getInputStream() throws IOException { - return this.fileContent.getInputStream(); - } - - public String getName() { - return this.fileContent.getName(); - } - - public String getPath() { - return this.fileContent.getPath(); - } - - public boolean isLeaf() { - return this.fileContent.isLeaf(); - } + final private FileContent fileContent; + + public WrappedFileContent(URL url) throws IOException { + String protocol = url.getProtocol(); + + if (protocol.equals("jar")) { + JarURLConnection jarConn = (JarURLConnection)url.openConnection(); + // Enumeration entries = jarConn.getJarFile().entries(); + String file = url.getFile(); + file = file.substring(file.lastIndexOf('!') + 1); + + // if (file.charAt(file.length() - 1) != '/') { + // + // int beginIndex; + // + // if (file.charAt(0) == '/') { + // beginIndex = 1; + // + // } else { + // beginIndex = 0; + // } + // + // file = file.substring(beginIndex); + // + // while (entries.hasMoreElements()) { + // String actualFile = entries.nextElement().getName(); + // + // if (actualFile.charAt(0) == '/') { + // beginIndex = 1; + // + // } else { + // beginIndex = 0; + // } + // + // if (actualFile.length() - beginIndex == file.length() + 1 && + // actualFile.charAt(actualFile.length() - 1) == '/') { + // + // if (actualFile.startsWith(file, beginIndex)) { + // file = actualFile; + // + // break; + // + // } + // + // } + // + // } + // + // } + + this.fileContent = ZipFileContent.createZipFileContent(jarConn.getJarFile(), file); + + } else if (protocol.equals("file")) { + this.fileContent = new SystemFileContent(new File(url.getFile())); + + } else { + this.fileContent = new DefaultFileContent(url); + } + + } + + public FileContent[] getChildren() { + return this.fileContent.getChildren(); + } + + public InputStream getInputStream() throws IOException { + return this.fileContent.getInputStream(); + } + + public String getName() { + return this.fileContent.getName(); + } + + public String getPath() { + return this.fileContent.getPath(); + } + + public boolean isLeaf() { + return this.fileContent.isLeaf(); + } } -- cgit v1.2.3