1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.cull;
35
import java.util.logging.Logger;
40
public class CullObject {
42
private Logger logger = Logger.getLogger("cullconv");
45
private ArrayList attrs = new ArrayList();
46
private ArrayList params = new ArrayList();
47
private String idlName;
49
private boolean hasAddOperation;
50
private boolean hasModifyOperation;
51
private boolean hasDeleteOperation;
52
private boolean hasGetOperation;
53
private boolean hasGetListOperation;
55
private boolean hasAddEvent;
56
private boolean hasModifyEvent;
57
private boolean hasDeleteEvent;
58
private boolean hasGetListEvent;
60
private String addEventName;
61
private String modifyEventName;
62
private String deleteEventName;
63
private String getListEventName;
65
private boolean rootObject;
66
private String listName;
68
public static final int TYPE_SIMPLE = 1;
69
public static final int TYPE_PRIMITIVE = 2;
70
public static final int TYPE_MAP = 3;
71
public static final int TYPE_MAPPED = 4;
73
private int type = TYPE_SIMPLE;
75
private CullObject parentObject;
76
private String parentName;
78
private String keyAttrName;
79
private String valueAttrName;
80
private String implClass;
82
private String contentAttrName;
84
/** Creates a new instance of CullObject */
89
* Getter for property name.
90
* @return Value of property name.
92
public java.lang.String getName() {
97
* Setter for property name.
98
* @param name New value of property name.
100
public void setName(java.lang.String name) {
105
public void addParam(String param ) {
109
public int getParamCount() {
110
return params.size();
113
public String getParam(int index) {
114
return (String)params.get(index);
117
public void addAttr( CullAttr attr ) {
118
if(!attr.isHidden()) {
119
logger.fine(getName() + ": add attr " + attr.getName());
121
attr.setParent( this );
123
primaryKeyAttrList = null;
127
private List attrList;
129
private void initAttrList() {
130
if(attrList == null) {
131
attrList = new ArrayList();
132
if(getParentObject() != null) {
133
attrList.addAll(getParentObject().getAttrList());
135
attrList.addAll(attrs);
140
* Get the number of attributes of this cull object
141
* incl. the attributes of the parent object
142
* return number of attributes
144
public int getAttrCount() {
146
return attrList.size();
150
* Get a list of all attributes of this cull object including
151
* the attributes of the parent object
152
* @return list of all attributes
154
public List getAttrList() {
156
return Collections.unmodifiableList(attrList);
160
* Get the attributes at index i
161
* @param i index of the attributes
162
* @return the attributes
164
public CullAttr getAttr( int i ) {
166
return (CullAttr)attrList.get(i);
170
* Get a attribute by its name
171
* @param name the name of the attribute
172
* @return the attributes
174
public CullAttr getAttr(String name) {
177
for(int i = 0; i < attrList.size(); i++ ) {
178
CullAttr tmp = (CullAttr)attrList.get(i);
179
if( tmp.getName().equals(name)) {
185
throw new IllegalArgumentException("attribute " + name + " not found in cull object " + getName() );
190
public int getOwnAttrCount() {
194
public List getOwnAttrList() {
195
return Collections.unmodifiableList(attrs);
198
public CullAttr getOwnAttr(int i) {
199
return (CullAttr)attrs.get(i);
202
public String getIdlName() {
206
public void setIdlName(String idlName) {
207
this.idlName = idlName;
211
private List primaryKeyAttrList;
213
private void initPrimaryKeyAttrList() {
214
if(primaryKeyAttrList == null) {
216
int type = this.type;
217
if(getParentObject() != null) {
218
type = getParentObject().getType();
221
if(type == TYPE_PRIMITIVE || type == TYPE_MAPPED) {
222
primaryKeyAttrList = Collections.EMPTY_LIST;
224
primaryKeyAttrList = new ArrayList();
226
for(int i = 0; i < getAttrCount(); i++) {
227
CullAttr attr = getAttr(i);
228
if( attr.isPrimaryKey() ) {
229
primaryKeyAttrList.add(attr);
236
public CullAttr getFirstPrimaryKeyAttr() {
237
initPrimaryKeyAttrList();
238
if(!primaryKeyAttrList.isEmpty()) {
239
return (CullAttr)primaryKeyAttrList.get(0);
245
public List getPrimaryKeyAttrs() {
246
initPrimaryKeyAttrList();
247
return Collections.unmodifiableList(primaryKeyAttrList);
250
public int getPrimaryKeyCount() {
251
initPrimaryKeyAttrList();
252
return primaryKeyAttrList.size();
255
public CullAttr getPrimaryKeyAttr(int i) {
256
initPrimaryKeyAttrList();
257
return (CullAttr)primaryKeyAttrList.get(i);
261
public boolean hasAddOperation() {
262
return hasAddOperation;
265
public void setHasAddOperation(boolean hasAddOperation) {
266
this.hasAddOperation = hasAddOperation;
269
public boolean hasModifyOperation() {
270
return hasModifyOperation;
273
public void setHasModifyOperation(boolean hasModifyOperation) {
274
this.hasModifyOperation = hasModifyOperation;
277
public boolean hasDeleteOperation() {
278
return hasDeleteOperation;
281
public void setHasDeleteOperation(boolean hasDeleteOperation) {
282
this.hasDeleteOperation = hasDeleteOperation;
285
public boolean hasGetOperation() {
286
return hasGetOperation;
289
public void setHasGetOperation(boolean hasGetOperation) {
290
this.hasGetOperation = hasGetOperation;
293
public boolean hasGetListOperation() {
294
return hasGetListOperation;
297
public void setHasGetListOperation(boolean hasGetListOperation) {
298
this.hasGetListOperation = hasGetListOperation;
301
public String getOperationString() {
302
StringBuffer ret = new StringBuffer();
303
if(hasGetOperation()) {
306
if(hasGetListOperation()) {
307
ret.append("GET_LIST ");
309
if(hasAddOperation()) {
312
if(hasModifyOperation()) {
313
ret.append("MODIFY ");
315
if(hasDeleteOperation()) {
316
ret.append("DELETE ");
318
return ret.toString();
321
public boolean isRootObject() {
325
public void setRootObject(boolean rootObject) {
326
this.rootObject = rootObject;
329
public int getType() {
330
if(getParentObject() != null) {
331
return getParentObject().getType();
336
public void setType(int type) {
340
public CullObject getParentObject() {
344
public void setParentObject(CullObject parentObject) {
345
this.parentObject = parentObject;
347
primaryKeyAttrList = null;
350
public String getParentName() {
354
public void setParentName(String parentName) {
355
this.parentName = parentName;
358
public String getKeyAttrName() {
359
String ret = keyAttrName;
360
if(ret == null && getParentObject() != null) {
361
ret = getParentObject().getKeyAttrName();
366
public void setKeyAttrName(String keyAttrName) {
367
this.keyAttrName = keyAttrName;
370
public CullAttr getKeyAttr() {
371
return getAttr(getKeyAttrName());
374
public String getValueAttrName() {
375
String ret = valueAttrName;
376
if(ret == null && getParentObject() != null) {
377
ret = getParentObject().getValueAttrName();
382
public CullAttr getValueAttr() {
383
return getAttr(getValueAttrName());
386
public void setValueAttrName(String valueAttrName) {
387
this.valueAttrName = valueAttrName;
390
public String getImplClass() {
391
String ret = implClass;
392
if(ret == null && getParentObject() != null) {
393
ret = getParentObject().getImplClass();
398
public void setImplClass(String implClass) {
399
this.implClass = implClass;
402
public String getContentAttrName() {
403
String ret = contentAttrName;
404
if(ret == null && getParentObject() != null) {
405
ret = getParentObject().getContentAttrName();
410
public void setContentAttrName(String contentAttrName) {
411
this.contentAttrName = contentAttrName;
414
public CullAttr getContentAttr() {
415
return getAttr(getContentAttrName());
418
public String getListName() {
422
public void setListName(String listName) {
423
this.listName = listName;
426
public boolean hasEvents() {
427
return hasAddEvent || hasModifyEvent || hasDeleteEvent || hasGetListEvent;
430
public boolean hasAddEvent() {
434
public void setHasAddEvent(boolean hasAddEvent) {
435
this.hasAddEvent = hasAddEvent;
438
public boolean hasModifyEvent() {
439
return hasModifyEvent;
442
public void setHasModifyEvent(boolean hasModifyEvent) {
443
this.hasModifyEvent = hasModifyEvent;
446
public boolean hasDeleteEvent() {
447
return hasDeleteEvent;
450
public void setHasDeleteEvent(boolean hasDeleteEvent) {
451
this.hasDeleteEvent = hasDeleteEvent;
454
public boolean hasGetListEvent() {
455
return hasGetListEvent;
458
public void setHasGetListEvent(boolean hasGetListEvent) {
459
this.hasGetListEvent = hasGetListEvent;
462
public String getAddEventName() {
466
public void setAddEventName(String addEventName) {
467
this.addEventName = addEventName;
470
public String getModifyEventName() {
471
return modifyEventName;
474
public void setModifyEventName(String modifyEventName) {
475
this.modifyEventName = modifyEventName;
478
public String getDeleteEventName() {
479
return deleteEventName;
482
public void setDeleteEventName(String deleteEventName) {
483
this.deleteEventName = deleteEventName;
486
public String getGetListEventName() {
487
return getListEventName;
490
public void setGetListEventName(String getListEventName) {
491
this.getListEventName = getListEventName;