KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > bridge > PrintInfoV1


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22 package org.enhydra.kelp.common.bridge;
23
24 // XMLC imports - 1.x and 2.x
25
import org.enhydra.xml.xmlc.dom.XMLCDocument;
26 import org.w3c.dom.*;
27
28 // Standard imports
29
import java.lang.reflect.Method JavaDoc;
30
31 //
32
public class PrintInfoV1 extends PrintInfo {
33
34     // string not to be resourced
35
private final String JavaDoc GET_URLS_METHOD = "getElementURLAttrs"; // nores
36

37     //
38
public PrintInfoV1(Document doc, XMLCDocument xmlcDoc) {
39         super(doc, xmlcDoc);
40     }
41
42     /**
43      * Append URLs from an element.
44      */

45     protected void getElementURLs(Element element, XMLCDocument xmlcDoc) {
46
47         // xmlcDoc.getElementURLAttrs(element);
48
String JavaDoc[] attrs = new String JavaDoc[0];
49         Method JavaDoc targetMethod = null;
50         Object JavaDoc[] args = new Object JavaDoc[1];
51
52         args[0] = element;
53         try {
54             Method JavaDoc[] methods = xmlcDoc.getClass().getMethods();
55
56             for (int i = 0; i < methods.length; i++) {
57                 if (methods[i].getName().equals(GET_URLS_METHOD)) {
58                     targetMethod = methods[i];
59                     break;
60                 }
61             }
62             if (targetMethod != null) {
63                 attrs = (String JavaDoc[]) targetMethod.invoke(xmlcDoc, args);
64             }
65             if (attrs == null) {
66                 return; // No URLs in this node.
67
}
68             for (int idx = 0; idx < attrs.length; idx++) {
69                 String JavaDoc url = element.getAttribute(attrs[idx]);
70
71                 if ((url != null) && (url.length() > 0)) {
72                     urls.addElement(url);
73                 }
74             }
75         } catch (Exception JavaDoc e) {
76             e.printStackTrace();
77         }
78     }
79
80 }
81
Popular Tags