Coverage details for umich.cac.data.NodeField

LineHitsSource
1 package umich.cac.data;
2  
3 import umich.cac.pbs.FieldFactory;
4  
5 /**
6  *
7  * This class encapsulates Node fields. A node consists of a nodename, and
8  * optionally a cpu.
9  *
10  * PBS encodes these together in a single field, using different separators.
11  *
12  * <p>
13  *
14  * An example rendering output from this Field would be
15  *
16  * <pre>
17  * &ltnode&gt
18  *
19  * &ltnodename&gtnode047&lt/nodename&gt
20  *
21  * &ltcpu&gt0&lt/cpu&gt
22  *
23  * &lt/node&gt
24  *
25  * </pre>
26  *
27  * @author rmach@umich.edu
28  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/NodeField.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $
29  *
30  */
31  
32 public class NodeField extends Field {
33  
34     
35     
36     /** Nodes and CPU's are seperated by / */
3727    private String NODE_SEPARATOR = "\\/";
38  
39     /** Node name is in position zero after split */
4027    private int NODENAME = 0;
41  
42     /** CPU is in position one after split */
4327    private int CPU = 1;
44  
45     /**
46      * Constructor for NodeField field, for a RESOURCE_USED field type
47      *
48      * @param fieldName
49      * Name of this field
50      * @param rawValue
51      * the raw value of this field from PBS accounting data
52      */
53  
54     public NodeField(FieldName fieldName, String rawValue) {
55  
5627        super(fieldName, rawValue, FieldType.RESOURCE_USED);
5727        setupChildren(rawValue);
58  
5927    }
60  
61     /**
62      * Alternate Constructor for NodeField field
63      *
64      * @param fieldName
65      * Name of this field
66      * @param rawValue
67      * the raw value of this field from PBS accounting data
68      * @param fieldType
69      * The field type this should be under=
70      */
71  
72     public NodeField(
73         FieldName fieldName,
74         String rawValue,
75         FieldType fieldType) {
76  
770        super(fieldName, rawValue, fieldType);
780        setupChildren(rawValue);
79  
800    }
81  
82     /**
83      *
84      * Contains children of type node. If just a hostname is encoded, only the
85      * NODENAME field
86      *
87      * is added. If a CPU and NAME are encoded both NODENAME and CPU fields are
88      * added.
89      *
90      * @param rawValue
91      * Description of the Parameter
92      *
93      */
94  
95     private void setupChildren(String rawValue) {
96  
9727        String[] nodeNameAndCpu = rawValue.split(NODE_SEPARATOR);
98  
99         //No CPU for this node type if field length is 1, otherwise if 2 we
100         // have a CPU added
101  
10227        if (nodeNameAndCpu.length == 1) {
103  
1040            Field nameNode =
105                 FieldFactory.getInstance().getField(
106                     FieldName.NODENAME,
107                     nodeNameAndCpu[NODENAME]);
1080            addChild(nameNode);
109  
11027        } else if (nodeNameAndCpu.length == 2) {
111  
11227            Field nameNode =
113                 FieldFactory.getInstance().getField(
114                     FieldName.NODENAME,
115                     nodeNameAndCpu[NODENAME]);
116  
11727            addChild(nameNode);
118  
11927            Field cpuNode =
120                 FieldFactory.getInstance().getField(
121                     FieldName.CPU,
122                     nodeNameAndCpu[CPU]);
123  
12427            addChild(cpuNode);
125  
126         }
127  
12827    }
129  
130 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.