01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: OzoneObjAttsFactory.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
08:
09: package org.ozoneDB.core.xml;
10:
11: import org.ozoneDB.OzoneObject;
12: import org.ozoneDB.core.ObjectID;
13:
14: import org.xml.sax.Attributes;
15: import org.xml.sax.helpers.AttributesImpl;
16:
17: /**
18: * Class for setting additional attributes in the obj-Tag,
19: * if the obj is an OzoneObject.
20: *
21: *
22: * @version $Revision: 1.1 $
23: * @author <a href="http://www.softwarebuero.de">SMB</a>
24: */
25: class OzoneObjAttsFactory implements ObjAttsFactory {
26:
27: //
28: // constants
29: //
30: public final static String ATTR_OBJNAME = "OzoneObjectName";
31: public final static String ATTR_OBJID = "OzoneObjectID";
32:
33: //
34: //constructor
35: //
36: public OzoneObjAttsFactory() {
37: }
38:
39: //
40: //method
41: //
42:
43: /**
44: * Method that returns additional attributes,
45: * if the Object is an OzoneObject.
46: *
47: * @param obj (the Object)
48: * @return Attributes (the additionally attributes)
49: */
50: public Attributes additionallyAtts(Object obj) {
51:
52: if (obj instanceof OzoneObject) {
53: ObjectID objID = ((OzoneObject) obj).container().id();
54: String name = ((OzoneObject) obj).container().name();
55: AttributesImpl atts = new AttributesImpl();
56: atts.addAttribute("", ATTR_OBJID, ATTR_OBJID, "long", ""
57: + objID.value());
58:
59: if (name != null) {
60: atts.addAttribute("", ATTR_OBJID, ATTR_OBJNAME,
61: "String", name);
62: }
63:
64: return atts;
65: } else {
66: return null;
67: }
68: }
69: }
|