1 /*2 * The contents of this file are subject to the terms of the Common Development3 * and Distribution License (the License). You may not use this file except in4 * compliance with the License.5 *6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html7 * or http://www.netbeans.org/cddl.txt.8 *9 * When distributing Covered Code, include this CDDL Header Notice in each file10 * and include the License file at http://www.netbeans.org/cddl.txt.11 * If applicable, add the following below the CDDL Header, with the fields12 * enclosed by brackets [] replaced by your own identifying information:13 * "Portions Copyrighted [year] [name of copyright owner]"14 *15 * The Original Software is NetBeans. The Initial Developer of the Original16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun17 * Microsystems, Inc. All Rights Reserved.18 */19 package org.netbeans.modules.xml.tools.generator;20 21 import java.util.*;22 import java.lang.reflect.Modifier ;23 24 //import org.openide.src.*;25 26 /**27 * Holds declared parslets by parslet name.28 * <!ELEMENT parslet #EMPTY>29 * <!ATTLIST parslet id ID #REQUIRED>30 * <!ATTLIST parslet return CDATA #REQUIRED> //primitive type or fully classified class31 */32 public class ParsletBindings extends HashMap {33 34 //TODO: Retouche35 // /** Serial Version UID */36 // private static final long serialVersionUID =5328744032505397530L;37 //38 //39 // // parameter names to generated methods40 // 41 // static final String DATA = "data"; // NOI18N42 // static final String META = "meta"; // NOI18N43 //44 // static final Type STRING_TYPE = Type.createFromClass (String.class);45 // 46 // static final MethodParameter DEFAULT_DATA_PARAMETER = 47 // new MethodParameter(DATA, STRING_TYPE, true);48 // 49 // static final MethodParameter[] DEFAULT_DATA_PARAMETERS = 50 // new MethodParameter[] { DEFAULT_DATA_PARAMETER }; 51 // 52 // /** Create empty map. */53 // public ParsletBindings() { 54 // }55 //56 // /** 57 // * Typed put.58 // * @see java.util.Map#put(Object,Object)59 // */60 // public Entry put(String parslet, String returnType) {61 // try {62 // return (Entry) super.put(parslet, new Entry(parslet, returnType));63 // } catch (SourceException ex) {64 // ex.printStackTrace();65 // return null;66 // }67 // }68 //69 // public Entry put(String parslet, Entry entry) {70 // if (parslet == null) return null;71 // if (parslet.equals(entry.getId()) == false) return null;72 // 73 // return (Entry) super.put(parslet, entry);74 // }75 // 76 // /** 77 // * Get a MethodParameter produced by given parslet.78 // * @param parslet id of parslet or null79 // * @return parslet return type as MethodParameter or DEFAULT_DATA_PARAMETER if null param80 // */81 // public MethodParameter getReturnAsParameter(String parslet) {82 // Entry param = seek(parslet);83 // if (param == null) {84 // return DEFAULT_DATA_PARAMETER;85 // } else {86 // return new MethodParameter(DATA, param.type, true);87 // }88 // }89 //90 // public Entry getEntry(String parslet) {91 // return (Entry) super.get(parslet);92 // }93 //94 // /** 95 // * Get return Type produced by given parslet.96 // * @param parslet id of parslet or null97 // * @return parslet return Type or String Type if null param98 // */ 99 // public Type getReturnType(String parslet) {100 //101 // Entry param = seek(parslet);102 // if (param == null) {103 // return STRING_TYPE;104 // } else {105 // return param.type;106 // } 107 // }108 //109 // /**110 // * Get Method element representing parslet method or null.111 // */112 // public MethodElement getMethod(String parslet) throws SourceException {113 // Entry param = seek(parslet);114 // if (param == null) {115 // return null;116 // } else {117 // MethodElement method = new MethodElement();118 // method.setName(Identifier.create(param.id));119 // method.setParameters(DEFAULT_DATA_PARAMETERS);120 // method.setReturn(param.type);121 // method.setModifiers(Modifier.PUBLIC);122 // method.setExceptions (new Identifier[] { Identifier.create("SAXException") }); // NOI18N123 // return method;124 // }125 // }126 //127 // /**128 // * Get parslet from map or null.129 // */130 // private Entry seek(String parslet) {131 // if (parslet == null) {132 // return null;133 // } else {134 // Entry param = (Entry) super.get(parslet);135 // if (param == null) {136 // return null;137 // } else {138 // return param;139 // }140 // } 141 // }142 // 143 // /**144 // * Holds information about a parslet.145 // * Not used yet.146 // */ 147 // public static final class Entry {148 //149 // /** Holds value of property parslet id. */150 // private String id;151 //152 // /** Holds value of property type. */153 // private org.openide.src.Type type;154 //155 // /** Creates new ParsletEntry */156 // public Entry(String id, String type) throws SourceException {157 // this.id = id;158 // this.type = Type.parse(type);159 // }160 //161 // /** 162 // * Getter for property id.163 // * @return Value of property id.164 // */165 // public String getId() {166 // return id;167 // }168 //169 // /** 170 // * Getter for property type.171 // * @return Value of property type.172 // */173 // public org.openide.src.Type getType() {174 // return type;175 // }176 //177 // void setReturnType(org.openide.src.Type type) {178 // this.type = type;179 // }180 //181 // public String toString() {182 // return "(" + id + " => " + type + ")"; // NOI18N183 // }184 // }185 }186