org.vrspace.client
Class VrmlUploader.URLParser

java.lang.Object
  extended byjava.util.Observable
      extended byorg.vrspace.client.VrmlParser
          extended byorg.vrspace.client.VrmlUploader.URLParser
Enclosing class:
VrmlUploader

public class VrmlUploader.URLParser
extends VrmlParser

Recursively parses given files, searching for url lists, in particular, other files on the local files system.


Field Summary
protected  java.util.HashMap cachedFiles
           
protected  java.util.HashMap files
           
protected  int maxRecursion
           
 
Fields inherited from class org.vrspace.client.VrmlParser
outputDir
 
Constructor Summary
protected VrmlUploader.URLParser(java.util.HashMap cachedFiles, java.util.HashMap files, int maxRecursion)
          Constructor designed for the recursive creation of this parser.
  VrmlUploader.URLParser(int maxRecursion)
           
 
Method Summary
protected  void cacheFile(java.lang.String uploadPath)
          Stores an entry in cachedFiles with key = path, and value = output.toString(), and resets the parser.
 java.util.HashMap getCachedFiles()
           
 java.util.HashMap getFiles()
           
 void parseFile(java.lang.String path)
          Parses the given file for all instances of urls.
 void parseFile(java.lang.String path, java.lang.String uploadPath)
           
protected  void parseFile(java.lang.String path, java.lang.String uploadPath, int recursionLevel)
          The actual file parsing workhorse.
protected  void parseFile(java.lang.String path, java.lang.String relRefPath, java.lang.String relRefUploadPath, int recursionLevel)
          Resolves path against relRefPath, refRefUploadPath, and calls parseFile on the result.
protected  void parseURL(java.lang.String urlString, java.lang.String path, java.lang.String uploadPath, int recursionLevel)
          Determines if the given urlString is a .wrl file, and continues recursive search if it is.
protected  java.lang.String resolvePath(java.lang.String path, java.lang.String relRefPath)
          Resolves the given path against relRefPath and returns the result.
protected  void storeFileReference(java.lang.String path, java.lang.String uploadPath)
          files with key = path, and value = path.
 
Methods inherited from class org.vrspace.client.VrmlParser
copyURL, copyURL, main, write
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cachedFiles

protected java.util.HashMap cachedFiles

files

protected java.util.HashMap files

maxRecursion

protected int maxRecursion
Constructor Detail

VrmlUploader.URLParser

public VrmlUploader.URLParser(int maxRecursion)

VrmlUploader.URLParser

protected VrmlUploader.URLParser(java.util.HashMap cachedFiles,
                                 java.util.HashMap files,
                                 int maxRecursion)
Constructor designed for the recursive creation of this parser.

Method Detail

getCachedFiles

public java.util.HashMap getCachedFiles()

getFiles

public java.util.HashMap getFiles()

parseFile

public void parseFile(java.lang.String path)
Parses the given file for all instances of urls. When these are found, if they reference .wrl files, then those files are recursively parsed. This recursion occurs up to the level set by maxRecursion. If the file is non-vrml, it is simply added to the list of uncached files.

VRML97 spec url is not java url - TODO

Overrides:
parseFile in class VrmlParser

parseFile

public void parseFile(java.lang.String path,
                      java.lang.String uploadPath)

parseFile

protected void parseFile(java.lang.String path,
                         java.lang.String uploadPath,
                         int recursionLevel)
The actual file parsing workhorse. ParseFile is called recursively on each file found in the url tags. Then the file being parsed is cached. If the file specified does not have a vrml extension, it simply stores the file reference in files. If recursionLevel > maxRecursion the method returns.


storeFileReference

protected void storeFileReference(java.lang.String path,
                                  java.lang.String uploadPath)
files with key = path, and value = path.


parseURL

protected void parseURL(java.lang.String urlString,
                        java.lang.String path,
                        java.lang.String uploadPath,
                        int recursionLevel)
Determines if the given urlString is a .wrl file, and continues recursive search if it is.


parseFile

protected void parseFile(java.lang.String path,
                         java.lang.String relRefPath,
                         java.lang.String relRefUploadPath,
                         int recursionLevel)
Resolves path against relRefPath, refRefUploadPath, and calls parseFile on the result.


resolvePath

protected java.lang.String resolvePath(java.lang.String path,
                                       java.lang.String relRefPath)
Resolves the given path against relRefPath and returns the result.


cacheFile

protected void cacheFile(java.lang.String uploadPath)
Stores an entry in cachedFiles with key = path, and value = output.toString(), and resets the parser. The path is expected to be absolute.