commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r515388 - in /jakarta/commons/sandbox/jci/trunk: compilers/javac/src/main/java/org/apache/commons/jci/compilers/ core/src/main/java/org/apache/commons/jci/listeners/ core/src/main/java/org/apache/commons/jci/utils/
Date Wed, 07 Mar 2007 00:18:02 GMT
Author: tcurdt
Date: Tue Mar  6 16:18:01 2007
New Revision: 515388

URL: http://svn.apache.org/viewvc?view=rev&rev=515388
Log:
move out some \ -> / conversion into utils,
hopefully fixed javac now under windows


Modified:
    jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java
    jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java
    jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java
    jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
    jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ClassUtils.java

Modified: jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java
Tue Mar  6 16:18:01 2007
@@ -8,6 +8,7 @@
 import java.io.InputStream;
 
 import org.apache.commons.jci.readers.ResourceReader;
+import org.apache.commons.jci.utils.ClassUtils;
 
 public class FileInputStreamProxy extends InputStream {
 	
@@ -29,7 +30,7 @@
 	}
 
 	public FileInputStreamProxy(String pName) throws FileNotFoundException {
-		name = pName;
+		name = ClassUtils.getResourceNameFromFileName(pName);
 
 		final ResourceReader reader = (ResourceReader) readerThreadLocal.get();
 
@@ -37,7 +38,13 @@
 			throw new RuntimeException("forgot to set the ResourceReader for this thread?");
 		}
 		
-		in = new ByteArrayInputStream(reader.getBytes(name));
+		final byte[] bytes = reader.getBytes(name);
+		
+		if (bytes == null) {
+			throw new FileNotFoundException(name);
+		}
+		
+		in = new ByteArrayInputStream(bytes);
 	}
 	
 	public int read() throws IOException {

Modified: jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java
Tue Mar  6 16:18:01 2007
@@ -8,6 +8,7 @@
 import java.io.OutputStream;
 
 import org.apache.commons.jci.stores.ResourceStore;
+import org.apache.commons.jci.utils.ClassUtils;
 
 public class FileOutputStreamProxy extends OutputStream {
 	
@@ -39,7 +40,7 @@
 	}
 
 	public FileOutputStreamProxy(String pName) throws FileNotFoundException {
-		name = pName;
+		name = ClassUtils.getResourceNameFromFileName(pName);
 	}
 	
 	public void write(int value) throws IOException {

Modified: jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java
Tue Mar  6 16:18:01 2007
@@ -17,7 +17,7 @@
 
 public final class JavacJavaCompiler extends AbstractJavaCompiler {
 
-	private static final String EOL = System.getProperty("line.separator");;
+	private static final String EOL = System.getProperty("line.separator");
 	private static final String WARNING_PREFIX = "warning: ";
 	private static final String NOTE_PREFIX = "Note: ";
 	private static final String ERROR_PREFIX = "error: ";

Modified: jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java
Tue Mar  6 16:18:01 2007
@@ -89,7 +89,7 @@
             for (Iterator it = deleted.iterator(); it.hasNext();) {
                 final File deletedFile = (File) it.next();
 
-                final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
deletedFile));
+                final String resourceName = ClassUtils.getResourceNameFromFileName(ClassUtils.relative(pObserver.getRootDirectory(),
deletedFile));
                 
                 if (resourceName.endsWith(".java")) {
                     transactionalStore.remove(
@@ -129,7 +129,7 @@
             final String[] sourceFiles = new String[compileables.size()];            
             for (Iterator it = compileables.iterator(); it.hasNext();) {
                 final File file = (File) it.next();
-                final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
+                final String resourceName = ClassUtils.getResourceNameFromFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                 sourceFiles[i] = resourceName;
                 i++;
             }

Modified: jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
Tue Mar  6 16:18:01 2007
@@ -62,14 +62,6 @@
     	
     }
     
-    public String getResourceNameFromRelativeFileName( final String pRelativeFileName ) {
-    	if ('/' == File.separatorChar) {
-    		return pRelativeFileName;
-    	}
-    	
-    	return pRelativeFileName.replace(File.separatorChar, '/');
-    }
-    
     public boolean isReloadRequired( final FilesystemAlterationObserver pObserver ) {
     	boolean reload = false;
     	
@@ -82,7 +74,7 @@
         if (deleted.size() > 0) {
             for (Iterator it = deleted.iterator(); it.hasNext();) {
                 final File file = (File) it.next();
-                final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
+                final String resourceName = ClassUtils.getResourceNameFromFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                 store.remove(resourceName);
             }
             reload = true;
@@ -95,7 +87,7 @@
                 try {
                 	is = new FileInputStream(file);
                     final byte[] bytes = IOUtils.toByteArray(is);
-                    final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
+                    final String resourceName = ClassUtils.getResourceNameFromFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                     store.write(resourceName, bytes);
                 } catch(final Exception e) {
                     log.error("could not load " + file, e);
@@ -112,7 +104,7 @@
                 try {
                 	is = new FileInputStream(file);
                     final byte[] bytes = IOUtils.toByteArray(is);
-                    final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
+                    final String resourceName = ClassUtils.getResourceNameFromFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                     store.write(resourceName, bytes);
                 } catch(final Exception e) {
                     log.error("could not load " + file, e);

Modified: jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ClassUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ClassUtils.java?view=diff&rev=515388&r1=515387&r2=515388
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ClassUtils.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ClassUtils.java
Tue Mar  6 16:18:01 2007
@@ -53,4 +53,18 @@
 		return relFileName;
 	}
 	
+	/**
+	 * a/b/c.java -> a/b/c.java
+	 * a\b\c.java -> a/b/c.java
+	 * @param pFileName
+	 * @return
+	 */
+    public static String getResourceNameFromFileName( final String pFileName ) {
+    	if ('/' == File.separatorChar) {
+    		return pFileName;
+    	}
+    	
+    	return pFileName.replace(File.separatorChar, '/');
+    }
+	
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message