* @version $Id$
*/
final public class TextureKey implements Savable {
+ /* There is a problem with the way that URLS are resolved in this class.
+ * The URL should only be resolved to read from them (and the resolved URL
+ * not saved).
+ * Resolving it at read() time means we have to save rooted URL. If the
+ * read in URL is relative, we losing the benefits of that relativity and
+ * if we later write(), we will save 'location' with an absolute URL. */
protected URL location = null;
protected boolean flipped;
+ fileType;
return x;
}
-}
\ No newline at end of file
+}
import com.jme.util.export.binary.modules.BinaryZBufferStateModule;
/**
- * @author mpowell
+ * This class is mis-named and is located in an inappropriate package:
+ * It is not binary-specific (it is in fact used for XML format too), and it
+ * is not a java.lang.ClassLoader, which is what "class loader" is for Java
+ * developers.
*
+ * @author mpowell
*/
public class BinaryClassLoader {
*/
public interface BinaryLoaderModule {
public String getKey();
+
+ /**
+ * The inputCapsule parameter is not used at all.
+ *
+ * The DOMOutputStream class calls this method with a null parameter, so
+ * if you make use of the parameter, either handle null 'inputCapsule'
+ * or rearrange the class hierarchy to satisfy DOMOuptutStream.
+ *
+ * @param inputCapsule A value which is currently ignored by all
+ * implementation classes.
+ */
public Savable load(InputCapsule inputCapsule) throws IOException;
}
import com.jme.util.TextureManager;
import com.jme.util.export.InputCapsule;
import com.jme.util.export.Savable;
+import com.jme.util.export.binary.BinaryClassLoader;
import com.jme.util.geom.BufferUtils;
/**
} else if (currentElem.hasAttribute("class")) {
className = currentElem.getAttribute("class");
}
- tmp = (Savable) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
+ tmp = BinaryClassLoader.fromName(className, null);
String refID = currentElem.getAttribute("reference_ID");
if (refID.length() < 1) refID = currentElem.getAttribute("id");
if (refID.length() > 0) referencedSavables.put(refID, tmp);
Element el = writtenSavables.get(object);
String className = null;
- if(!object.getClass().getName().equals(name)){
- className = object.getClass().getName();
+ if(!object.getClassTag().getName().equals(name)){
+ className = object.getClassTag().getName();
}
try {
doc.createElement(name);
} catch (DOMException e) {
+ // Ridiculous fallback behavior.
+ // Would be far better to throw than to totally disregard the
+ // specified "name" and write a class name instead!
+ // (Besides the fact we are clobbering the managed .getClassTag()).
name = "Object";
className = object.getClass().getName();
}
return new XMLImporter();
}
+ /*
+ * This returns rooted URLs, so you can use them to load resources.
+ *
+ * For persistence purposes, you should store the input to this method,
+ * not the output, because the input may be relative whereas the output is
+ * rooted to ensure it can load its resource successfully.
+ *
+ * @see com.jme.util.resource.RelativeRsoruceLocator#locateResource(String)
+ */
public URL locateResource(String resourceName) {
if (baseUri == null || resourceName == null
|| resourceName.length() < 1 || resourceName.charAt(0) == '/'
private static final Logger logger =
Logger.getLogger(AbsoluteResourceLocator.class.getName());
- private Pattern baseUriPattern = null;
- private URL pathlessBaseUrl = null;
+ private Pattern baseUriPattern;
+ private URL pathlessBaseUrl;
/**
* Instantiate a locator for any resource present at the specified
* absolute resource path.
*/
public AbsoluteResourceLocator() {
+ try {
+ pathlessBaseUrl = new URL("file:");
+ } catch (MalformedURLException mue) {
+ throw new RuntimeException(mue);
+ }
}
/**
* </P>
*
* @param baseURI <B>IMPORTANT</B>: The whole purpose here is to specify
- * a path with an absolue path to validate against.
+ * a path with an absolute path to validate against.
* Therefore, to cover an entire web site, you must use
* <CODE>http://pub.admc.com/</CODE>, not
* <CODE>http://pub.admc.com</CODE>.
* @throws IllegalArgumentException if the specified baseUri does not have
- * an absolue URI path, or is otherwise unacceptable.
+ * an absolute URI path, or is otherwise unacceptable.
*/
public AbsoluteResourceLocator(URI baseUri) {
-logger.severe("base url: " + baseUri);
String basePath = baseUri.getPath();
// Every test I run shows a real getPath(), but there may be URI types,
// current or future, which I have not tested, therefore...
}
/*
+ * This returns rooted URLs, so you can use them to load resources.
+ *
+ * For persistence purposes, you should store the input to this method,
+ * not the output, because the input may be relative whereas the output is
+ * rooted to ensure it can load its resource successfully.
+ *
* @returns null if resource not found, according to algorithm specified
* in the class JavaDoc.
* @see RelativeResourceLocator