|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ExampleLabel
Shows examples of using the PDSLabel package.
Constructor Summary | |
(package private) |
ExampleLabel()
|
Method Summary | |
static void |
Basic(java.lang.String[] args)
Parse a label and print it to the screen. |
static void |
Delete(java.lang.String[] args)
Parse a label, remove an object and print the results to the screen. |
static void |
Extract(java.lang.String[] args)
Parse a label, find an object, extract the object into a new label and print it to the screen. |
static void |
LoadWrite(java.lang.String[] args)
Parse a label and write it to another file. |
static void |
main(java.lang.String[] args)
|
static void |
Object(java.lang.String[] args)
Parse a label, locate an object and print the object to the screen. |
static void |
PadFile(java.lang.String[] args)
Pad a file so that every line in the file has the same number of characters. |
static void |
Pointer(java.lang.String[] args)
Parse a label and print all elements that are pointers to the screen. |
static void |
PointerInObject(java.lang.String[] args)
Parse a label, find an object, find pointers with the object and print each pointer to the screen. |
static void |
PointerList(java.lang.String[] args)
Parse a label, find all the pointers to files and print the list of files to the screen. |
static void |
PointerValue(java.lang.String[] args)
Parse a label, find a pointer, print the pointer and the element that follows the pointer. |
static void |
Structure(java.lang.String[] args)
Parse a label, find a pointer element, parse the file it references and print it to the screen. |
static void |
StructureReplace(java.lang.String[] args)
Parse a label and replace a pointer with the contents of the file it references, then print the label to the screen. |
static void |
Value(java.lang.String[] args)
Parse a label, find an element, then extract and print the value of the element. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
ExampleLabel()
Method Detail |
public static void main(java.lang.String[] args)
public static void Basic(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
label.parse(file); // Parse label file
label.print(); // Print label
public static void Object(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSItem
object;
label.parse(file); // Parse label file
object = label.findObject(name); // Find object
label.print(System.out, 4, 20, object); // Print object
public static void Pointer(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSItem
item = new PDSItem();
label.parse(file); // Parse label file
item.empty(); // Clear item
while(true) {
item = label.findNextElement("^*", item); // Find next pointer
if(!item.valid()) break; // If none - exit loop
label.print(System.out, 4, 20, item); // Print item
}
public static void PointerInObject(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSItem
item = new PDSItem();
label.parse(file); // Parse label file
object = label.findObject("TABLE"); // Find TABLE object
item = label.findElement("^*", object); // Find first pointer in TABLE object
label.print(System.out, 4, 20, item); // Print element
public static void PointerValue(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSItem
item = new PDSItem();
label.parse(file); // Parse label file
item.empty(); // Clear item
item = label.findNextElement("^*", item); // Find first pointer
System.out.print("next element after: ");
label.print(System.out, 4, 20, item); // Print item found
item = label.nextElement(item); // Step to next item
label.print(System.out, 4, 20, item); // Print item found
public static void Structure(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSLabel
partial = new PDSLabel();
PDSItem
item;
PDSElement
element;
PDSValue
value;
label.parse(file); // Parse label file
item = label.findElement("^STRUCTURE"); // Find pointer to STRUCTURE
if(item.valid()) { // If found
element = label.getElement(item); // Get element associated with item
value = (PDSValue) element.mValue.get(0); // Get value
partial.parse(label.path() + value.mValue); // Parse file
partial.print(); // Print out label ^STRUCTURE points to
} else {
System.out.println("Element not found!");
}
public static void StructureReplace(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSLabel
partial = new PDSLabel();
PDSItem
item;
PDSElement
element;
PDSValue
value;
label.parse(file); // Parse label file
item = label.findElement("^STRUCTURE"); // Find pointer to STRUCTURE
if(item.valid()) { // If found
element = label.getElement(item); // Get element associated with item
value = (PDSValue) element.mValue.get(0); // Get value
partial.parse(label.path() + value.mValue); // Parse file
partial.print(System.out, 4, 20); // Print out label ^STRUCTURE points to
} else {
System.out.println("Element not found!");
}
if(item.valid()) {
label.replace(item, partial); // Replace ^STRUCTURE item with parsed file content
label.print(System.out, 4, 20); // Print the whole label
}
public static void Value(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSLabel
partial = new PDSLabel();
PDSItem
item = new PDSItem();
PDSElement
element;
PDSValue
value;
System.out.println("== Extract an element - value item method ===========");
label.parse(file); // Parse label file
item.empty(); // Clear item
item = label.findNextElement(name, item); // Find item
if(item.valid()) { // If found
element = label.getElement(item); // Get element associated with item
if(element != null) {
int n;
System.out.println("Keyword: " + element.mKeyword); // Print keyword
n = element.mValue.size(); // Determine number of values
System.out.println("N Value: " + n); // Print count
for(int i = 0; i < n; i++) {
value = (PDSValue) element.mValue.get(i); // Get value item
System.out.print("Value: " + value.mValue); // Get value of item
System.out.println("\tUnits: " + value.mUnits); // Get units of item
}
}
label.print(System.out, 4, 20, item); // Print formated element
} else { // not found
System.out.println("Unable to find item: " + name);
}
System.out.println("== Extract an element - indirect method ===========");
item.empty(); // Clear item
item = label.findNextElement(name, item); // Find item
if(item.valid()) { // If found
element = label.getElement(item); // Get element associated with item
if(element != null) {
int n;
System.out.println("Keyword: " + element.mKeyword); // Print keyword
n = element.valueSize(); // Determine number of values
System.out.println("N Value: " + n); // Print count
for(int i = 0; i < n; i++) {
System.out.print("Value: " + element.value(i)); // Get value for item
System.out.println("\tUnits: " + element.units(i)); // Get units for item
}
}
label.print(System.out, 4, 20, item); // Print formatted element
} else { // not found
System.out.println("Unable to find item: " + name);
}
public static void Delete(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSItem
object;
label.parse(file); // Parse label file
object = label.findObject(name); // Find object
if(object.valid()) label.remove(object);
label.print();
public static void Extract(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
PDSLabel
partial;
PDSItem
object;
label.parse(file); // Parse label file
object = label.findObject(name); // Find object
if(object.valid()) {
partial = label.extract(object); // Extract object into new label
partial.print(); // Print new label
}
public static void PointerList(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
ArrayList
list;
label.parse(file); // Parse label file
list = label.filePointers();
for(int i = 0; i < list.size(); i++) {
System.out.println("File: " + (String) list.get(i));
}
public static void LoadWrite(java.lang.String[] args)
PDSLabel
label = new PDSLabel();
System.out.println("== Load label and write to a file ============");
label.parse(file); // Parse label file
label.print(output);
public static void PadFile(java.lang.String[] args)
PDSUtil
util = new PDSUtil();
System.out.println("== Pad file ============");
util.padFile(file); // Pad file
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |