Package org.opensourcephysics.tools
Class LibraryComPADRE
java.lang.Object
org.opensourcephysics.tools.LibraryComPADRE
This provides static methods for getting a LibraryCollection from ComPADRE.
Adapted from code written for EJS by Francisco Esquembre.
- Version:
- 1.0
- Author:
- Francisco Esquembre, Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllChildren
(Node parent, String name) Returns all child nodes with the given name.protected static org.opensourcephysics.tools.LibraryResource.Attachment
getAttachment
(Node node, String[] attachmentTypes) Returns data for a downloadable DOM Node attachment.protected static String
getChildValue
(Node parent, String name) Gets the value of the first child node with a given name.protected static LibraryCollection
getCollection
(String path) Returns the LibraryCollection for a given ComPADRE path (query).static String
getCollectionName
(String path) Returns a descriptive name for a given ComPADRE path (query).protected static String
getCollectionPath
(String path, boolean primarySubjectOnly) Returns the collection path for an EJS or tracker tree.protected static Node
getFirstChild
(Node parent, String name) Returns the first child node with the given name.protected static String
getNodeValue
(Node node) Gets the value of a Node.protected static boolean
isComPADREPath
(String path) Determines if a path is a ComPADRE query.protected static boolean
isDesiredOSPType
(Node node) Determines if a node has an <osp-type> consistent with desiredOSPType.protected static boolean
isPrimarySubjectOnly
(String path) Determines if a query path limits results to the primary subject only.protected static boolean
isTrackerType
(Node node) protected static boolean
load
(LibraryCollection collection, String query) Loads a collection using a specified comPADRE search query.protected static void
loadNode
(Node node, LibraryCollection collection, LibraryTreeNode treeNode, String urlPath, Runnable onFound, Runnable onNothingNew) protected static void
loadResources
(LibraryTreeNode treeNode, Runnable onSuccess, Runnable onFailure) Loads ComPADRE records into a LibraryTreeNode collection.protected static boolean
loadSubtrees
(LibraryCollection collection, NodeList nodeList, String attributeType, String serviceParameter) Loads a collection with subtree collections that meet the specified requirements.protected static String
processURL
(String url) Replaces "&" with "&" in HTML code.protected static void
reloadResource
(LibraryTreeNode treeNode, String urlPath, Runnable whenDone) Reloads a ComPADRE record into a LibraryTreeNode.protected static boolean
setRecord
(LibraryResource record, Node node, org.opensourcephysics.tools.LibraryResource.Attachment attachment, LibraryTreeNode treeNode) Sets a LibraryTreeNode to a ComPADRE record.protected static void
protected static String
writeXmlFile
(Document doc, String filename) Writes a DOM document to a file for testing.
-
Field Details
-
OSP_INFO_URL
- See Also:
-
EJS_SERVER_TREE
- See Also:
-
EJS_SERVER_RECORDS
- See Also:
-
EJS_COLLECTION_NAME
- See Also:
-
EJS_INFO_URL
- See Also:
-
TRACKER_SERVER_TREE
- See Also:
-
TRACKER_SERVER_RECORDS
- See Also:
-
TRACKER_COLLECTION_NAME
- See Also:
-
TRACKER_INFO_URL
- See Also:
-
PRIMARY_ONLY
- See Also:
-
GENERIC_COLLECTION_NAME
- See Also:
-
ABOUT_OSP
- See Also:
-
HOST
- See Also:
-
COMPADRE_QUERY
- See Also:
-
desiredOSPType
-
-
Constructor Details
-
LibraryComPADRE
public LibraryComPADRE()
-
-
Method Details
-
load
Loads a collection using a specified comPADRE search query.- Parameters:
collection
- the LibraryCollection to loadquery
- the search query- Returns:
- true if successfully loaded
-
loadSubtrees
protected static boolean loadSubtrees(LibraryCollection collection, NodeList nodeList, String attributeType, String serviceParameter) Loads a collection with subtree collections that meet the specified requirements.- Parameters:
collection
- the LibraryCollection to loadnodeList
- a list of NodesattributeType
- the desired attributeserviceParameter
- the desired service parameter- Returns:
- true if at least one subtree collection was loaded
-
loadResources
protected static void loadResources(LibraryTreeNode treeNode, Runnable onSuccess, Runnable onFailure) Loads ComPADRE records into a LibraryTreeNode collection.- Parameters:
treeNode
- the LibraryTreeNode to load--note record MUST be a collection
-
start
-
loadNode
protected static void loadNode(Node node, LibraryCollection collection, LibraryTreeNode treeNode, String urlPath, Runnable onFound, Runnable onNothingNew) -
reloadResource
Reloads a ComPADRE record into a LibraryTreeNode.- Parameters:
treeNode
- the LibraryTreeNode to reload
-
setRecord
protected static boolean setRecord(LibraryResource record, Node node, org.opensourcephysics.tools.LibraryResource.Attachment attachment, LibraryTreeNode treeNode) Sets a LibraryTreeNode to a ComPADRE record.- Parameters:
treeNode
- the LibraryTreeNode to set- Returns:
- true if successfully set
-
getAttachment
protected static org.opensourcephysics.tools.LibraryResource.Attachment getAttachment(Node node, String[] attachmentTypes) Returns data for a downloadable DOM Node attachment.- Parameters:
node
- the DOM NodeattachmentType
- the attachment type- Returns:
- Attachment, or null if no attachment found
-
getFirstChild
Returns the first child node with the given name.- Parameters:
parent
- the parent Nodename
- the child name- Returns:
- the first child Node found, or null if none
-
getAllChildren
Returns all child nodes with the given name.- Parameters:
parent
- the parent Nodename
- the name- Returns:
- a list of Nodes (may be empty)
-
getNodeValue
Gets the value of a Node.- Parameters:
node
- the Node- Returns:
- the value
-
getChildValue
Gets the value of the first child node with a given name.- Parameters:
parent
- the parent Nodename
- the name of the child- Returns:
- the value of the first child found, or null if none
-
processURL
Replaces "&" with "&" in HTML code.- Parameters:
url
- the HTML code- Returns:
- the clean URL string
-
writeXmlFile
Writes a DOM document to a file for testing.- Parameters:
doc
- the Documentfilename
- the filename to write to- Returns:
- the String contents of the document
-
getCollectionName
Returns a descriptive name for a given ComPADRE path (query).- Parameters:
path
- the query string- Returns:
- the name of the collection
-
getCollection
Returns the LibraryCollection for a given ComPADRE path (query).- Parameters:
path
- the query string- Returns:
- the collection
-
getCollectionPath
Returns the collection path for an EJS or tracker tree.- Parameters:
path
- the ComPADRE query stringprimarySubjectOnly
- true to limit results to their primary subject- Returns:
- the corrected ComPADRE query string
-
isComPADREPath
Determines if a path is a ComPADRE query.- Parameters:
path
- the path- Returns:
- true if path starts with the standard partial ComPADRE query string
-
isPrimarySubjectOnly
Determines if a query path limits results to the primary subject only.- Parameters:
path
- the path- Returns:
- true if path contains a primary-subject-only flag
-
isDesiredOSPType
Determines if a node has an <osp-type> consistent with desiredOSPType.- Parameters:
node
- the node- Returns:
- true if is of the desired <osp-type>
-
isTrackerType
-