01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * 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;
30:
31: //
32: public class PrintInfoV1 extends PrintInfo {
33:
34: // string not to be resourced
35: private final String 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[] attrs = new String[0];
49: Method targetMethod = null;
50: Object[] args = new Object[1];
51:
52: args[0] = element;
53: try {
54: Method[] 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[]) 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 url = element.getAttribute(attrs[idx]);
70:
71: if ((url != null) && (url.length() > 0)) {
72: urls.addElement(url);
73: }
74: }
75: } catch (Exception e) {
76: e.printStackTrace();
77: }
78: }
79:
80: }
|