KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > xml > OzoneObjAttsFactory


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: OzoneObjAttsFactory.java,v 1.2 2002/08/27 08:32:26 per_nyfelt Exp $
8

9 package org.ozoneDB.core.xml;
10
11 import org.ozoneDB.OzoneObject;
12 import org.ozoneDB.core.ObjectID;
13
14 import org.xml.sax.Attributes JavaDoc;
15 import org.xml.sax.helpers.AttributesImpl JavaDoc;
16
17
18 /**
19  * Class for setting additional attributes in the obj-Tag,
20  * if the obj is an OzoneObject.
21  *
22  *
23  * @version $Revision: 1.2 $
24  * @author <a HREF="http://www.softwarebuero.de">SMB</a>
25  */

26 class OzoneObjAttsFactory implements ObjAttsFactory {
27
28     //
29
// constants
30
//
31
public final static String JavaDoc ATTR_OBJNAME = "OzoneObjectName";
32     public final static String JavaDoc ATTR_OBJID = "OzoneObjectID";
33
34
35     //
36
//constructor
37
//
38
public OzoneObjAttsFactory() {
39     }
40
41
42     //
43
//method
44
//
45

46
47     /**
48      * Method that returns additional attributes,
49      * if the Object is an OzoneObject.
50      *
51      * @param obj (the Object)
52      * @return Attributes (the additionally attributes)
53      */

54     public Attributes JavaDoc additionallyAtts( Object JavaDoc obj ) {
55
56         if (obj instanceof OzoneObject) {
57             ObjectID objID = ((OzoneObject)obj).container().id();
58             String JavaDoc name = ((OzoneObject)obj).container().name();
59             AttributesImpl JavaDoc atts = new AttributesImpl JavaDoc();
60             atts.addAttribute( "", ATTR_OBJID, ATTR_OBJID, "long", "" + objID.value() );
61
62             if (name != null) {
63                 atts.addAttribute( "", ATTR_OBJID, ATTR_OBJNAME, "String", name );
64             }
65
66             return atts;
67         } else {
68             return null;
69         }
70     }
71 }
72
Popular Tags