KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > report > utils > PathTagMapping


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.editors.report.utils;
20
21 import java.util.HashMap JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 import org.openharmonise.him.harmonise.*;
25
26
27 /**
28  * Mapping of Harmonise paths to report query element names.
29  *
30  * @author Matthew Large
31  * @version $Revision: 1.1 $
32  *
33  */

34 public class PathTagMapping {
35
36     /**
37      * Map of path to Harmonise object element names.
38      */

39     private static HashMap JavaDoc m_pathObjectTagMapping = new HashMap JavaDoc();
40
41     /**
42      * Map of path to Harmonise group element names.
43      */

44     private static HashMap JavaDoc m_pathGroupTagMapping = new HashMap JavaDoc();
45
46     static {
47         m_pathObjectTagMapping.put(HarmonisePaths.PATH_ASSETS, "Asset");
48         m_pathObjectTagMapping.put(HarmonisePaths.PATH_DOCUMENTS, "Document");
49         m_pathObjectTagMapping.put(HarmonisePaths.PATH_COMPOSITION, "XMLResource");
50         m_pathObjectTagMapping.put(HarmonisePaths.PATH_INCLUDES, "XMLResource");
51         m_pathObjectTagMapping.put(HarmonisePaths.PATH_NEWSLETTER, "Document");
52         m_pathObjectTagMapping.put(HarmonisePaths.PATH_PAGE_DEFINITION, "Page");
53         m_pathObjectTagMapping.put(HarmonisePaths.PATH_PROPERTIES, "Property");
54         m_pathObjectTagMapping.put(HarmonisePaths.PATH_RBS_PROPS, "Property");
55         m_pathObjectTagMapping.put(HarmonisePaths.PATH_RBS_VALS, "Value");
56         m_pathObjectTagMapping.put(HarmonisePaths.PATH_REPORTS, "XMLResource");
57         m_pathObjectTagMapping.put(HarmonisePaths.PATH_SITE_ASSETS, "Asset");
58         m_pathObjectTagMapping.put(HarmonisePaths.PATH_USERS, "User");
59         m_pathObjectTagMapping.put(HarmonisePaths.PATH_VALUES, "Value");
60         m_pathObjectTagMapping.put(HarmonisePaths.PATH_WORKFLOW_DEFINITIONS, "Value");
61         m_pathObjectTagMapping.put(HarmonisePaths.PATH_WORKFLOW_PROPS, "Property");
62         m_pathObjectTagMapping.put(HarmonisePaths.PATH_WORKFLOW_STAGES, "Value");
63         m_pathObjectTagMapping.put(HarmonisePaths.PATH_XSLT, "XSLTResource");
64
65         m_pathGroupTagMapping.put(HarmonisePaths.PATH_ASSETS, "Section");
66         m_pathGroupTagMapping.put(HarmonisePaths.PATH_DOCUMENTS, "Section");
67         m_pathGroupTagMapping.put(HarmonisePaths.PATH_COMPOSITION, "XMLResourceGroup");
68         m_pathGroupTagMapping.put(HarmonisePaths.PATH_INCLUDES, "XMLResourceGroup");
69         m_pathGroupTagMapping.put(HarmonisePaths.PATH_NEWSLETTER, "Section");
70         m_pathGroupTagMapping.put(HarmonisePaths.PATH_PAGE_DEFINITION, "PageGroup");
71         m_pathGroupTagMapping.put(HarmonisePaths.PATH_PROPERTIES, "PropertyGroup");
72         m_pathGroupTagMapping.put(HarmonisePaths.PATH_RBS_PROPS, "PropertyGroup");
73         m_pathGroupTagMapping.put(HarmonisePaths.PATH_RBS_VALS, "ValueGroup");
74         m_pathGroupTagMapping.put(HarmonisePaths.PATH_REPORTS, "XMLResourceGroup");
75         m_pathGroupTagMapping.put(HarmonisePaths.PATH_SITE_ASSETS, "Section");
76         m_pathGroupTagMapping.put(HarmonisePaths.PATH_USERS, "UserGroup");
77         m_pathGroupTagMapping.put(HarmonisePaths.PATH_VALUES, "ValueGroup");
78         m_pathGroupTagMapping.put(HarmonisePaths.PATH_WORKFLOW_DEFINITIONS, "ValueGroup");
79         m_pathGroupTagMapping.put(HarmonisePaths.PATH_WORKFLOW_PROPS, "PropertyGroup");
80         m_pathGroupTagMapping.put(HarmonisePaths.PATH_WORKFLOW_STAGES, "ValueGroup");
81         m_pathGroupTagMapping.put(HarmonisePaths.PATH_XSLT, "XSLTResourceGroup");
82     }
83
84     /**
85      *
86      */

87     private PathTagMapping() {
88         super();
89     }
90     
91     /**
92      * Returns the tag name for a given object path.
93      *
94      * @param sPath Full path
95      * @return Tag name
96      */

97     public static String JavaDoc getObjectTagName(String JavaDoc sPath) {
98         String JavaDoc sTagName = null;
99         
100         Iterator JavaDoc itor = m_pathObjectTagMapping.keySet().iterator();
101         while (itor.hasNext()) {
102             String JavaDoc element = (String JavaDoc) itor.next();
103             if(sPath.startsWith(element)) {
104                 sTagName = (String JavaDoc) m_pathObjectTagMapping.get(element);
105                 break;
106             }
107         }
108         
109         return sTagName;
110     }
111     
112     /**
113      * Returns the tag name for a given group path.
114      *
115      * @param sPath Full path
116      * @return Tag name
117      */

118     public static String JavaDoc getGroupTagName(String JavaDoc sPath) {
119         String JavaDoc sTagName = null;
120         
121         Iterator JavaDoc itor = m_pathGroupTagMapping.keySet().iterator();
122         while (itor.hasNext()) {
123             String JavaDoc element = (String JavaDoc) itor.next();
124             if(sPath.startsWith(element)) {
125                 sTagName = (String JavaDoc) m_pathGroupTagMapping.get(element);
126                 break;
127             }
128         }
129         
130         return sTagName;
131     }
132 }
133
Popular Tags