From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch14.util;
02
03 /**
04 * A classclass is a group of fields and methods used for making objects forfor is a looping structure for repeatedly executing a block of code holding an attribute and a value together. An
05 * AttributeValuePair compares to another by comparing only the
06 * attribute fields. Two pairs with the same attribute name are
07 * considered the same.
08 */
09 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects AttributeValuePair
10 implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparable<AttributeValuePair> {open braces start code blocks and must be matched with a close brace
11 /** the name of the attribute */
12 privateprivate is used to restrict access to the current class only finalfinal means not changeable (often used for constants) String attribute;
13
14 /** the value of the named attribute */
15 privateprivate is used to restrict access to the current class only String value;
16
17 /**
18 * Construct a newnew is used to create objects by calling the constructor attribute-value pair with the given name and value.
19 *
20 * @paramthis is the Javadoc tag for documenting the purpose of parameters attribute name of the attribute
21 * @paramthis is the Javadoc tag for documenting the purpose of parameters value value of the attribute
22 */
23 publicpublic is used to indicate unrestricted access (any other class can have access) AttributeValuePair(String attribute, String value) {open braces start code blocks and must be matched with a close brace
24 thisthis means the current object (the implicit parameter).attribute =this assignment operator makes the left side equal to the right side attribute;
25 thisthis means the current object (the implicit parameter).value =this assignment operator makes the left side equal to the right side value;
26 }close braces end code blocks and must match an earlier open brace
27
28 /**
29 * Compare to another {open braces start code blocks and must be matched with a close brace@link AttributeValuePair}close braces end code blocks and must match an earlier open brace. Comparison is based
30 * solely on the attribute portion of each pair.
31 *
32 * @paramthis is the Javadoc tag for documenting the purpose of parameters rhs the right-hand-side of the comparison (the thisthis means the current object (the implicit parameter)
33 * reference is lhs).
34 *
35 * @returnnull negative, 0, positive forfor is a looping structure for repeatedly executing a block of code comes before, equals, or comes
36 * after rhs.
37 */
38 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer compareTo(AttributeValuePair rhs) {open braces start code blocks and must be matched with a close brace
39 returnreturn means to provide the result of the method and/or cease execution of the method immediately attribute.compareTo(rhs.attribute);
40 }close braces end code blocks and must match an earlier open brace
41
42 /**
43 * Get the name of the attribute in the attribute-value pair
44 *
45 * @returnnull the attribute
46 */
47 publicpublic is used to indicate unrestricted access (any other class can have access) String getAttribute() {open braces start code blocks and must be matched with a close brace
48 returnreturn means to provide the result of the method and/or cease execution of the method immediately attribute;
49 }close braces end code blocks and must match an earlier open brace
50
51 /**
52 * Get the value
53 *
54 * @returnnull the value of the attribute
55 */
56 publicpublic is used to indicate unrestricted access (any other class can have access) String getValue() {open braces start code blocks and must be matched with a close brace
57 returnreturn means to provide the result of the method and/or cease execution of the method immediately value;
58 }close braces end code blocks and must match an earlier open brace
59
60 /**
61 * Set the value
62 *
63 * @paramthis is the Javadoc tag for documenting the purpose of parameters value the value to set
64 */
65 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setValue(String value) {open braces start code blocks and must be matched with a close brace
66 thisthis means the current object (the implicit parameter).value =this assignment operator makes the left side equal to the right side value;
67 }close braces end code blocks and must match an earlier open brace
68
69 /* (non-Javadoc)
70 * @seethis is the Javadoc tag for documenting a related piece of documentation java.lang.Object#toString()
71 */
72 @Override
73 publicpublic is used to indicate unrestricted access (any other class can have access) String toString() {open braces start code blocks and must be matched with a close brace
74 returnreturn means to provide the result of the method and/or cease execution of the method immediately attribute +adds two numbers together or concatenates Strings together "=" +adds two numbers together or concatenates Strings together value;
75 }close braces end code blocks and must match an earlier open brace
76 }close braces end code blocks and must match an earlier open brace
77
78 //Uploaded on Mon Mar 29 21:42:33 EDT 2010
|
Download/View scg/ch14/util/AttributeValuePair.java