2 * Copyright (c) 2003-2004 Christopher Lenz and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API and implementation
11 * $Id: AbstractProfile.java,v 1.1 2004-09-02 18:07:14 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.core.profiles;
16 import java.util.Collection;
17 import java.util.Collections;
18 import java.util.HashMap;
19 import java.util.HashSet;
23 import net.sourceforge.phpeclipse.css.core.internal.model.PropertyInfo;
24 import net.sourceforge.phpeclipse.css.core.model.IPropertyInfo;
27 * Abstract implementation of the <code>IProfile</code> interface.
29 public abstract class AbstractProfile implements IProfile {
31 // Instance Variables ------------------------------------------------------
34 * The associated descriptor, as passed into the constructor by the profile
35 * manager when the profile is instantiated.
37 private IProfileDescriptor descriptor;
40 * Map of the property names of this profile, containing the
41 * <code>IPropertyInfo</code> objects keyed by property name.
43 private Map properties = new HashMap();
46 * Set of the at rule keywords known to the profile.
48 private Set atKeywords = new HashSet();
51 * Set of the at pseudo-classes known to the profile.
53 private Set pseudoClasses = new HashSet();
55 // Constructors ------------------------------------------------------------
60 * @param descriptor the profile descriptor
62 public AbstractProfile(IProfileDescriptor descriptor) {
63 this.descriptor = descriptor;
66 // IProfile Implementation -------------------------------------------------
69 * @see net.sourceforge.phpeclipse.css.core.profiles.IProfile#getDescriptor()
71 public final IProfileDescriptor getDescriptor() {
72 return this.descriptor;
76 * @see IProfile#getAtKeywords()
78 public final Collection getAtKeywords() {
79 return Collections.unmodifiableSet(this.atKeywords);
83 * @see IProfile#getProperties()
85 public final Collection getProperties() {
86 return Collections.unmodifiableSet(this.properties.keySet());
90 * @see IProfile#getPropertyInfo(java.lang.String)
92 public final IPropertyInfo getPropertyInfo(String propertyName) {
93 return (IPropertyInfo) this.properties.get(propertyName);
97 * @see IProfile#getPseudoClassNames()
99 public final Collection getPseudoClassNames() {
100 return Collections.unmodifiableSet(this.pseudoClasses);
103 // Protected Methods -------------------------------------------------------
105 protected final void addAtKeyword(String atKeyword) {
106 this.atKeywords.add(atKeyword);
109 protected final void addProperty(String name, String category) {
110 addProperty(new PropertyInfo(name, category));
113 protected final void addProperty(String name, String category,
115 addProperty(new PropertyInfo(name, category, shorthand));
118 protected final void addProperty(IPropertyInfo info) {
119 this.properties.put(info.getName(), info);
122 protected final void addPseudoClass(String pseudoClass) {
123 this.pseudoClasses.add(pseudoClass);