Author: akazakov
Date: 2011-08-24 15:03:16 -0400 (Wed, 24 Aug 2011)
New Revision: 34239
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
Log:
Fixed NPE:
Caused by: java.lang.NullPointerException
at
org.jboss.tools.jst.web.kb.include.IncludeContextDefinition.addTagAttribute(IncludeContextDefinition.java:170)
at
org.jboss.tools.jst.web.kb.include.IncludeContextBuilder.processAttributeElement(IncludeContextBuilder.java:170)
at
org.jboss.tools.jst.web.kb.include.IncludeContextBuilder.readElement(IncludeContextBuilder.java:230)
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java 2011-08-24
18:10:57 UTC (rev 34238)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java 2011-08-24
19:03:16 UTC (rev 34239)
@@ -25,11 +25,11 @@
*/
public class IncludeContextDefinition {
private String fUri;
- private Map<String, Set<String>> fIncludeTags; // Map<TagName,
Set<AttributeName>>
- private Map<String, Set<String>> fCSSTags; // Map<TagName,
Set<AttributeName>>
- private Map<String, Set<String>> fJSF2CSSTags; // Map<TagName,
Set<AttributeName>>
- private Map<String, Set<String>> fContexts; // Map<ContextType,
Set<ContentType>>
-
+ private Map<String, Set<String>> fIncludeTags = new HashMap<String,
Set<String>>(); // Map<TagName, Set<AttributeName>>
+ private Map<String, Set<String>> fCSSTags = new HashMap<String,
Set<String>>(); // Map<TagName, Set<AttributeName>>
+ private Map<String, Set<String>> fJSF2CSSTags = new HashMap<String,
Set<String>>(); // Map<TagName, Set<AttributeName>>
+ private Map<String, Set<String>> fContexts = new HashMap<String,
Set<String>>(); // Map<ContextType, Set<ContentType>>
+
/**
* Created the IncludeContextDefinition object for the specified URI
*
@@ -87,9 +87,6 @@
* @param element
*/
private void addIncludeTag(String tagName, IConfigurationElement element) {
- if (fIncludeTags == null) {
- fIncludeTags = new HashMap<String, Set<String>>();
- }
Set<String> tagSet = fIncludeTags.get(tagName);
if (tagSet == null) {
tagSet = new HashSet<String>();
@@ -104,9 +101,6 @@
* @param element
*/
private void addCSSTag(String tagName, IConfigurationElement element) {
- if (fCSSTags == null) {
- fCSSTags = new HashMap<String, Set<String>>();
- }
Set<String> tagSet = fCSSTags.get(tagName);
if (tagSet == null) {
tagSet = new HashSet<String>();
@@ -121,9 +115,6 @@
* @param element
*/
private void addJSF2CSSTag(String tagName, IConfigurationElement element) {
- if (fJSF2CSSTags == null) {
- fJSF2CSSTags = new HashMap<String, Set<String>>();
- }
Set<String> tagSet = fJSF2CSSTags.get(tagName);
if (tagSet == null) {
tagSet = new HashSet<String>();
@@ -202,9 +193,6 @@
* @param element
*/
public void addContextType(String id, IConfigurationElement element) {
- if (fContexts == null) {
- fContexts = new HashMap<String, Set<String>>();
- }
Set<String> contextSet = fContexts.get(id);
if (contextSet == null) {
contextSet = new HashSet<String>();
@@ -249,7 +237,7 @@
* @return
*/
public String[] getIncludeTags() {
- return fIncludeTags == null ? EMPTY_CHILDREN :
+ return fIncludeTags.isEmpty() ? EMPTY_CHILDREN :
(String[])fIncludeTags.keySet().toArray(new String[fIncludeTags.size()]);
}
@@ -259,7 +247,7 @@
* @return
*/
public String[] getCSSTags() {
- return fCSSTags == null ? EMPTY_CHILDREN :
+ return fCSSTags.isEmpty() ? EMPTY_CHILDREN :
(String[])fCSSTags.keySet().toArray(new String[fCSSTags.size()]);
}
/**
@@ -268,7 +256,7 @@
* @return
*/
public String[] getJSF2CSSTags() {
- return fJSF2CSSTags == null ? EMPTY_CHILDREN :
+ return fJSF2CSSTags.isEmpty() ? EMPTY_CHILDREN :
(String[])fJSF2CSSTags.keySet().toArray(new String[fJSF2CSSTags.size()]);
}
@@ -319,13 +307,10 @@
* @return
*/
public String getContextType(String contentType) {
- if (fContexts == null)
- return null;
-
for (String contextType : fContexts.keySet()) {
if (fContexts.get(contextType).contains(contentType))
return contextType;
}
return null;
}
-}
+}
\ No newline at end of file