KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > util > ExtractUtils


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Sun Public License Notice
26  *
27  * The contents of this file are subject to the Sun Public License
28  * Version 1.0 (the "License"). You may not use this file except in
29  * compliance with the License. A copy of the License is available at
30  * http://www.sun.com/
31  *
32  * The Original Code is NetBeans. The Initial Developer of the Original
33  * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
34  * Microsystems, Inc. All Rights Reserved.
35  */

36
37 // PENDING copied from ejbmodule data object
38

39 package com.sun.enterprise.tools.common.util;
40
41 import org.netbeans.modules.jarpackager.api.ArchiveEntry;
42 import com.sun.forte4j.j2ee.lib.dd.ejb2.gen.EjbJar;
43 import com.sun.forte4j.j2ee.lib.dataobject.J2eeDataObject;
44
45 public class ExtractUtils {
46     
47     /**
48      * convert an icon urls into an icon references.
49      *
50      * @param url a string representing the url of an icon.
51      * @return The name of the ArchiveEntry in a form appropriate for
52      * putting in a deployment descriptor.
53      */

54     static String JavaDoc urlToReference(String JavaDoc url) {
55         if ((url == null) ||
56             (url.equals("null")) || // NOI18N
57
(url.length() == 0) ) {
58             return null;
59         }
60         // Make an ArchiveEntry.
61
// This is a little bit inefficient as we throw this away
62
// and it will be made again later.
63
ArchiveEntry archiveEntry = J2eeDataObject.urlToArchiveEntry(url);
64         return archiveEntry.getName();
65     }
66
67     /**
68      * Copy the UserInfo .
69      * Also convert icon urls into icon references.
70      *
71      * @param from copy from here
72      * @param to copy to here
73      */

74     static public void copyUserInfo(EjbJar from, EjbJar to) {
75         String JavaDoc url;
76         String JavaDoc reference;
77
78         url = from.getLargeIcon();
79         reference = urlToReference(url);
80         to.setLargeIcon(reference);
81
82         url = from.getSmallIcon();
83         reference = urlToReference(url);
84         to.setSmallIcon(reference);
85         
86 // System.out.println("Copying " + from.getDescription()); //NOI18N
87

88         to.setDescription(from.getDescription());
89         to.setDisplayName(from.getDisplayName());
90     }
91 }
92
Popular Tags