001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * File : LanguageParserSettings.java
044: * Created on : Oct 27, 2003
045: * Author : Aztec
046: */
047: package org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework;
048:
049: import java.util.HashMap;
050:
051: import javax.swing.plaf.SplitPaneUI;
052:
053: import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
054: import org.netbeans.modules.uml.core.support.umlutils.ETList;
055:
056: /**
057: * @author Aztec
058: */
059: public class LanguageParserSettings implements ILanguageParserSettings {
060: HashMap<String, String> m_SettingMap = new HashMap<String, String>();
061: HashMap<String, ETList<ILanguageMacro>> m_LanguageMacrosMap = new HashMap<String, ETList<ILanguageMacro>>();
062:
063: /* (non-Javadoc)
064: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#addMacro(java.lang.String, org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageMacro)
065: */
066: public void addMacro(String language, ILanguageMacro macro) {
067: ETList<ILanguageMacro> spLanguageMacros = ensureLanguageMacros(language);
068: spLanguageMacros.add(macro);
069: }
070:
071: /* (non-Javadoc)
072: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#addSetting(java.lang.String, java.lang.String, java.lang.String)
073: */
074: public void addSetting(String language, String name, String value) {
075: m_SettingMap.put(name, value);
076: }
077:
078: /* (non-Javadoc)
079: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#getAllMacros()
080: */
081: public ETList<ILanguageMacro> getAllMacros() {
082: return null;
083: }
084:
085: /* (non-Javadoc)
086: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#getMacro(java.lang.String, java.lang.String)
087: */
088: public ILanguageMacro getMacro(String language, String name) {
089: if (language == null || name == null)
090: return null;
091:
092: ETList<ILanguageMacro> spLanguageMacros = ensureLanguageMacros(language);
093: ILanguageMacro spLanguageMacro = null;
094: int lCount = spLanguageMacros.size();
095: for (int i = 0; i < lCount; i++) {
096: spLanguageMacro = spLanguageMacros.get(i);
097: if (spLanguageMacro != null) {
098: if (name.equals(spLanguageMacro.getName()))
099: return spLanguageMacro;
100: }
101: }
102: return null;
103: }
104:
105: /* (non-Javadoc)
106: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#getMacros(java.lang.String)
107: */
108: public ETList<ILanguageMacro> getMacros(String language) {
109: return ensureLanguageMacros(language);
110: }
111:
112: /* (non-Javadoc)
113: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguageParserSettings#getSetting(java.lang.String, java.lang.String)
114: */
115: public String getSetting(String language, String name) {
116: if (language == null || name == null)
117: return null;
118:
119: return m_SettingMap.get(name);
120: }
121:
122: private ETList<ILanguageMacro> ensureLanguageMacros(String language) {
123: if (language == null)
124: return null;
125:
126: ETList<ILanguageMacro> spLanguageMacros = null;
127: if (m_LanguageMacrosMap != null) {
128: spLanguageMacros = m_LanguageMacrosMap.get(language);
129: }
130: if (spLanguageMacros == null) {
131: spLanguageMacros = new ETArrayList<ILanguageMacro>();
132: // Add to the macro map.
133: m_LanguageMacrosMap.put(language, spLanguageMacros);
134: }
135: return spLanguageMacros;
136: }
137: }
|