Package org.opensourcephysics.controls
Class XML
java.lang.Object
org.opensourcephysics.controls.XML
This defines the ObjectLoader interface and static methods for managing and
accessing ObjectLoader implementations.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceThis defines methods for moving xml data between an XMLControl and a corresponding Java object. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateFolders(String path) Creates any missing folders in the specified path.static StringforwardSlash(String path) Replaces backslashes with slashes.static StringgetAbsolutePath(File file) Gets the absolute path of the specified file.static Stringstatic ClassLoaderGets the ClassLoader.static StringgetDirectoryPath(String fileName) Gets the path of the directory containing the specified file.static StringGets the DTD for the specified doctype file name.static StringgetExtension(String fileName) Gets the extension of the specified file name.static XML.ObjectLoaderGets the ObjectLoader for the specified class.static StringGets the name from the specified path.static StringgetPathRelativeTo(String absolutePath, String base) Gets the path relative to the specified base directory.static StringgetRelativePath(String absolutePath) Gets a path relative to the default user directory.static StringgetResolvedPath(String relativePath, String base) Resolves the name of a file specified relative to a base path.static StringgetSimpleClassName(Class<?> type) Gets a simple class name for the specified class type.static StringGets the default user directory.static StringremoveCDATA(String content) static booleanrequiresCDATA(String text) Determines whether the specified string requires CDATA tags.static voidsetClassLoader(ClassLoader loader) Sets the ClassLoader.static voidsetDefaultLoader(XML.ObjectLoader loader) Sets the default ObjectLoader.static voidsetLoader(Class<?> classtype, XML.ObjectLoader loader) Sets the ObjectLoader for a specified class.static StringstripExtension(String fileName) Strips the extension from the specified file name.
-
Field Details
-
NEW_LINE
-
CDATA_PRE
- See Also:
-
CDATA_PRE_LEN
public static final int CDATA_PRE_LEN- See Also:
-
CDATA_POST
- See Also:
-
CDATA_POST_LEN
public static final int CDATA_POST_LEN- See Also:
-
CDATA_POST_PROP
- See Also:
-
INDENT
public static final int INDENT- See Also:
-
-
Method Details
-
setLoader
Sets the ObjectLoader for a specified class.- Parameters:
classtype- the classloader- the ObjectLoader
-
getLoader
Gets the ObjectLoader for the specified class.- Parameters:
classtype- the class- Returns:
- the ObjectLoader
-
setDefaultLoader
Sets the default ObjectLoader. May be set to null.- Parameters:
loader- the ObjectLoader
-
getAttr
-
requiresCDATA
Determines whether the specified string requires CDATA tags.- Parameters:
text- the string- Returns:
trueif CDATA tags are required
-
getDTD
Gets the DTD for the specified doctype file name.- Parameters:
doctype- the doctype file name (e.g., "osp10.dtd")- Returns:
- the DTD as a string
-
setClassLoader
Sets the ClassLoader.- Parameters:
loader- the classLoader
-
getClassLoader
Gets the ClassLoader. May be null.- Returns:
- the classLoader
-
forwardSlash
Replaces backslashes with slashes.- Parameters:
path- the path- Returns:
- the path with forward slashes
-
getName
Gets the name from the specified path.- Parameters:
path- the full path- Returns:
- the name alone
-
getExtension
Gets the extension of the specified file name.- Parameters:
fileName- the file name with or without path- Returns:
- the extension, or null if none
-
getSimpleClassName
Gets a simple class name for the specified class type.- Parameters:
type- the class- Returns:
- the simple class name
-
stripExtension
Strips the extension from the specified file name.- Parameters:
fileName- the file name with or without path- Returns:
- the file name without extension
-
getPathRelativeTo
Gets the path relative to the specified base directory.- Parameters:
absolutePath- the absolute pathbase- the absolute base directory path- Returns:
- (with forward slashes) the path relative to the base, or the absolutePath if no relative path is found (eg, different drive) or the absolutePath if it is really a relative path
-
getRelativePath
Gets a path relative to the default user directory.- Parameters:
absolutePath- the absolute path- Returns:
- the relative path, with forward slashes
-
getUserDirectory
Gets the default user directory.- Returns:
- the user directory
-
getDirectoryPath
Gets the path of the directory containing the specified file.- Parameters:
fileName- the full file name, including path- Returns:
- the directory path, with forward slashes
-
getAbsolutePath
Gets the absolute path of the specified file.- Parameters:
file- the file- Returns:
- the absolute path, with forward slashes
-
getResolvedPath
Resolves the name of a file specified relative to a base path.- Parameters:
relativePath- the relative file namebase- the absolute base path- Returns:
- the resolved file name with forward slashes
-
createFolders
Creates any missing folders in the specified path.- Parameters:
path- the path to construct
-
removeCDATA
-