Author: nscavell
Date: 2011-05-30 09:41:47 -0400 (Mon, 30 May 2011)
New Revision: 6576
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
Log:
GTNPORTAL-1905: Minor change for declaring optional elements in application specific
parser.
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java 2011-05-30
13:36:30 UTC (rev 6575)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java 2011-05-30
13:41:47 UTC (rev 6576)
@@ -29,6 +29,8 @@
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
+import java.util.Set;
+
/**
* @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
* @version $Revision$
@@ -64,11 +66,17 @@
public abstract ApplicationState<S> parseApplicationState() throws
StaxNavException;
- public abstract boolean isElementOptional(StAXElement stAXElement) throws
StaxNavException;
+ public abstract Set<StAXElement> getOptionalElements();
@Override
public final boolean isOptional(StAXElement staxElement)
{
+ Set<StAXElement> optional = getOptionalElements();
+ if (optional != null && optional.contains(staxElement))
+ {
+ return true;
+ }
+
switch (staxElement)
{
case theme:
@@ -82,7 +90,7 @@
return true;
default:
- return isElementOptional(staxElement);
+ return false;
}
}
}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java 2011-05-30
13:36:30 UTC (rev 6575)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java 2011-05-30
13:41:47 UTC (rev 6576)
@@ -25,6 +25,9 @@
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
+import java.util.Collections;
+import java.util.Set;
+
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/19/11
@@ -47,8 +50,8 @@
}
@Override
- public boolean isElementOptional(StAXElement staxElement)
+ public Set<StAXElement> getOptionalElements()
{
- return false;
+ return Collections.emptySet();
}
}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-30
13:36:30 UTC (rev 6575)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-30
13:41:47 UTC (rev 6576)
@@ -27,7 +27,10 @@
import org.staxnav.StaxNavigator;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
import java.util.List;
+import java.util.Set;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
@@ -84,18 +87,11 @@
}
}
+ private static final Set<StAXElement> optionalElements =
EnumSet.of(StAXElement.preferences, StAXElement.value, StAXElement.read_only);
+
@Override
- public boolean isElementOptional(StAXElement staxElement)
+ public Set<StAXElement> getOptionalElements()
{
- switch(staxElement)
- {
- case preferences:
- case value:
- case read_only:
- return true;
-
- default:
- return false;
- }
+ return Collections.unmodifiableSet(optionalElements);
}
}