001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.tmap.model.impl;
020:
021: import java.util.ArrayList;
022: import java.util.Collection;
023: import java.util.Collections;
024: import org.netbeans.modules.xslt.tmap.model.api.Service;
025: import org.netbeans.modules.xslt.tmap.model.api.Operation;
026: import org.netbeans.modules.xslt.tmap.model.api.Invoke;
027: import org.netbeans.modules.xslt.tmap.model.api.Transform;
028: import org.netbeans.modules.xslt.tmap.model.api.Param;
029: import org.netbeans.modules.xslt.tmap.model.api.TMapComponent;
030:
031: /**
032: *
033: * @author Vitaly Bychkov
034: * @version 1.0
035: */
036: public enum TMapComponents {
037: TRANSFORM_MAP("transformmap", ChildrenTypes.TRANSFORM_MAP_CHILDREN), // NOI18N
038: SERVICE("service", ChildrenTypes.SERVICE_CHILDREN), // NOI18N
039: OPERATION("operation", ChildrenTypes.OPERATION_CHILDREN), // NOI18N
040: INVOKE("invoke", ChildrenTypes.INVOKE_CHILDREN), // NOI18N
041: TRANSFORM("transform", ChildrenTypes.TRANSFORM_CHILDREN), // NOI18N
042: PARAM("param", ChildrenTypes.PARAM_CHILDREN);// NOI18N
043:
044: private String myTagName;
045: private ChildrenTypes myChildrenTypes;
046:
047: private TMapComponents(String tagName, ChildrenTypes childrenTypes) {
048: myTagName = tagName;
049: myChildrenTypes = childrenTypes;
050: }
051:
052: public String getTagName() {
053: return myTagName;
054: }
055:
056: public Collection<Class<? extends TMapComponent>> getChildTypes() {
057: return myChildrenTypes.getTypes();
058: }
059:
060: public static enum ChildrenTypes {
061: TRANSFORM_MAP_CHILDREN(createTransformMap()), SERVICE_CHILDREN(
062: createService()), OPERATION_CHILDREN(createOperation()), INVOKE_CHILDREN(
063: createInvoke()), TRANSFORM_CHILDREN(createTransform()), PARAM_CHILDREN(
064: createParam());
065:
066: private Collection<Class<? extends TMapComponent>> myTypes;
067:
068: private ChildrenTypes(
069: Collection<Class<? extends TMapComponent>> types) {
070: myTypes = types;
071: }
072:
073: public Collection<Class<? extends TMapComponent>> getTypes() {
074: return myTypes;
075: }
076:
077: private static Collection<Class<? extends TMapComponent>> createTransformMap() {
078: Collection<Class<? extends TMapComponent>> children = new ArrayList<Class<? extends TMapComponent>>(
079: 1);
080: children.add(Service.class);
081: return children;
082: }
083:
084: private static Collection<Class<? extends TMapComponent>> createService() {
085: Collection<Class<? extends TMapComponent>> children = new ArrayList<Class<? extends TMapComponent>>(
086: 1);
087: children.add(Operation.class);
088: return children;
089: }
090:
091: private static Collection<Class<? extends TMapComponent>> createOperation() {
092: Collection<Class<? extends TMapComponent>> children = new ArrayList<Class<? extends TMapComponent>>(
093: 2);
094: children.add(Invoke.class);
095: children.add(Transform.class);
096: return children;
097: }
098:
099: private static Collection<Class<? extends TMapComponent>> createInvoke() {
100: Collection<Class<? extends TMapComponent>> children = Collections
101: .emptyList();
102: return children;
103: }
104:
105: private static Collection<Class<? extends TMapComponent>> createTransform() {
106: Collection<Class<? extends TMapComponent>> children = new ArrayList<Class<? extends TMapComponent>>(
107: 1);
108: children.add(Param.class);
109: return children;
110: }
111:
112: private static Collection<Class<? extends TMapComponent>> createParam() {
113: Collection<Class<? extends TMapComponent>> children = Collections
114: .emptyList();
115: return children;
116: }
117: }
118:
119: }
|