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 interface
static interface
This defines methods for moving xml data between an XMLControl and a corresponding Java object. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
createFolders
(String path) Creates any missing folders in the specified path.static String
forwardSlash
(String path) Replaces backslashes with slashes.static String
getAbsolutePath
(File file) Gets the absolute path of the specified file.static String
static ClassLoader
Gets the ClassLoader.static String
getDirectoryPath
(String fileName) Gets the path of the directory containing the specified file.static String
Gets the DTD for the specified doctype file name.static String
getExtension
(String fileName) Gets the extension of the specified file name.static XML.ObjectLoader
Gets the ObjectLoader for the specified class.static String
Gets the name from the specified path.static String
getPathRelativeTo
(String absolutePath, String base) Gets the path relative to the specified base directory.static String
getRelativePath
(String absolutePath) Gets a path relative to the default user directory.static String
getResolvedPath
(String relativePath, String base) Resolves the name of a file specified relative to a base path.static String
getSimpleClassName
(Class<?> type) Gets a simple class name for the specified class type.static String
Gets the default user directory.static String
removeCDATA
(String content) static boolean
requiresCDATA
(String text) Determines whether the specified string requires CDATA tags.static void
setClassLoader
(ClassLoader loader) Sets the ClassLoader.static void
setDefaultLoader
(XML.ObjectLoader loader) Sets the default ObjectLoader.static void
setLoader
(Class<?> classtype, XML.ObjectLoader loader) Sets the ObjectLoader for a specified class.static String
stripExtension
(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:
true
if 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
-