KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > parser > lib > ParserUtils


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.parser.lib;
27
28 import java.net.URL JavaDoc;
29
30 import org.objectweb.util.explorer.ExplorerUtils;
31 import org.objectweb.util.explorer.core.code.api.CodeDescription;
32 import org.objectweb.util.explorer.core.code.lib.BasicCodeDescription;
33 import org.objectweb.util.explorer.core.icon.api.IconDescription;
34 import org.objectweb.util.explorer.core.icon.lib.BasicIconCodeDescription;
35 import org.objectweb.util.explorer.core.icon.lib.BasicIconFileDescription;
36 import org.objectweb.util.explorer.explorerConfig.Code;
37 import org.objectweb.util.explorer.explorerConfig.Icon;
38
39 /**
40  * Useful toolkit for Parser component.
41  *
42  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
43  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
44  *
45  * @version 0.1
46  */

47 public class ParserUtils {
48
49     //==================================================================
50
//
51
// Internal States.
52
//
53
// ==================================================================
54

55     // ==================================================================
56
//
57
// Constructors.
58
//
59
// ==================================================================
60

61     // ==================================================================
62
//
63
// Internal method.
64
//
65
// ==================================================================
66

67     // ==================================================================
68
//
69
// Public methods.
70
//
71
// ==================================================================
72

73     /**
74      * Provides a Code description for the given code element.
75      */

76     public static CodeDescription getCodeDescription(Code code){
77         CodeDescription cd = new BasicCodeDescription();
78         cd.setLanguage(code.getLanguage());
79         cd.setCode(code.getValue());
80         return cd;
81     }
82
83     /**
84      * Provides an Icon description for the given icon element.
85      */

86     public static IconDescription getIconDescription(Icon icon){
87         IconDescription iconDescription = null;
88         if(icon!=null){
89             if (icon.getIconFile()!=null) {
90                 URL JavaDoc url = ExplorerUtils.getURL(icon.getIconFile().getUrl());
91                 if(url!=null){
92                     iconDescription = new BasicIconFileDescription();
93                     ((BasicIconFileDescription)iconDescription).setURL(url);
94                 }
95             } else if (icon.getCode()!=null) {
96                 CodeDescription codeDesc = getCodeDescription(icon.getCode());
97                 if(codeDesc!=null){
98                     iconDescription = new BasicIconCodeDescription();
99                     ((BasicIconCodeDescription)iconDescription).setCode(codeDesc);
100                 }
101             }
102         }
103         return iconDescription;
104     }
105         
106 }
107
108
109
Popular Tags