You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/06/12 14:38:32 UTC
svn commit: r1349299 [2/4] - in /incubator/wookie/trunk:
parser/java/src-test/org/apache/wookie/w3c/test/
parser/java/src/org/apache/wookie/w3c/
parser/java/src/org/apache/wookie/w3c/impl/
parser/java/src/org/apache/wookie/w3c/updates/ parser/java/src/...
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/ILocalized.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/ILocalized.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/ILocalized.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/ILocalized.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c;
+
+/**
+ * An element that can be localized by language tag
+ */
+public interface ILocalized {
+
+ /**
+ * Get the language tag for the element. This should conform to BCP47.
+ * @return the language tag, or null if no language tag has been set for the element
+ */
+ public String getLang();
+
+ /**
+ * Set the language tag for the element.
+ * @param lang a language tag to set; this should conform to BCP47.
+ */
+ public void setLang(String lang);
+
+}
\ No newline at end of file
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IName.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IName.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IName.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IName.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,53 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c;
+
+/**
+ * A Name of a Widget
+ */
+public interface IName extends ILocalized, IDirectional {
+
+ /**
+ * Get widget short name.
+ *
+ * @return short name
+ */
+ String getShort();
+
+ /**
+ * Set widget short name.
+ *
+ * @param shortName short name
+ */
+ void setShort(String shortName);
+
+ /**
+ * Get widget name.
+ *
+ * @return name
+ */
+ String getName();
+
+ /**
+ * Set widget name.
+ *
+ * @param name name
+ */
+ void setName(String name);
+
+}
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IParam.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IParam.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IParam.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IParam.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,49 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c;
+
+/**
+ * A Name/Value parameter
+ */
+public interface IParam {
+
+ /**
+ * Get widget feature parameter name.
+ *
+ * @return parameter name
+ */
+ String getName();
+
+ /**
+ * Set widget feature parameter name.
+ */
+ void setName(String name);
+
+ /**
+ * Get widget feature parameter value.
+ *
+ * @return parameter value
+ */
+ String getValue();
+
+ /**
+ * Set widget feature parameter value.
+ */
+ void setValue(String value);
+
+}
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IPreference.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IPreference.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IPreference.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IPreference.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c;
+
+/**
+ *
+ */
+public interface IPreference extends IParam {
+
+ public boolean isReadOnly();
+
+ public void setReadOnly(boolean readOnly);
+
+}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IStartPageProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IStartPageProcessor.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IStartPageProcessor.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IStartPageProcessor.java Tue Jun 12 12:38:28 2012
@@ -28,7 +28,7 @@ public interface IStartPageProcessor {
* @throws IOException if there is a problem reading or writing to the start file, or if the start file cannot be parsed
* with the HTML processor used
*/
- public abstract void processStartFile(File startFile, W3CWidget model, IContentEntity content)
+ public abstract void processStartFile(File startFile, W3CWidget model, IContent content)
throws Exception;
}
\ No newline at end of file
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java Tue Jun 12 12:38:28 2012
@@ -22,7 +22,7 @@ import java.util.List;
* This represents the information model for a W3C widget that has been
* unpacked using the W3CWidgetFactory.
*/
-public interface W3CWidget extends ILocalizedEntity{
+public interface W3CWidget extends ILocalized, IDirectional {
/**
* Get the default locale
@@ -33,15 +33,15 @@ public interface W3CWidget extends ILoca
/**
* Get the list of access request entities for the widget
*/
- public List<IAccessEntity> getAccessList();
+ public List<IAccess> getAccessList();
/**
* Get the list of start pages for the widget
*/
- public List<IContentEntity> getContentList();
+ public List<IContent> getContentList();
/**
* Get the list of icons for the widget
*/
- public List<IIconEntity> getIconsList();
+ public List<IIcon> getIcons();
/**
* Get the widget identifier (IRI)
*/
@@ -49,15 +49,15 @@ public interface W3CWidget extends ILoca
/**
* Get the list of Licenses for the widget
*/
- public List<ILicenseEntity> getLicensesList();
+ public List<ILicense> getLicenses();
/**
* Get the list of Names for the widget
*/
- public List<INameEntity> getNames();
+ public List<IName> getNames();
/**
* Get the list of Descriptions for the widget
*/
- public List<IDescriptionEntity> getDescriptions();
+ public List<IDescription> getDescriptions();
/**
* Get the widget height as an Integer. Note this may be Null.
*/
@@ -69,16 +69,16 @@ public interface W3CWidget extends ILoca
/**
* Get the Author information for the widget
*/
- public IAuthorEntity getAuthor();
+ public IAuthor getAuthor();
/**
* Get the list of Preferences defined for the widget
*/
- public List<IPreferenceEntity> getPrefences();
+ public List<IPreference> getPreferences();
/**
* Get a list of Features requested by the widget. Note that only valid
* features are included (e.g. ones supported by the platform, or that are defined by the widget as optional)
*/
- public List<IFeatureEntity> getFeatures();
+ public List<IFeature> getFeatures();
/**
* Get the version of the widget
*/
@@ -96,8 +96,8 @@ public interface W3CWidget extends ILoca
* This is equivalent to:
*
* <code>
- * List<INameEntity> names = widget.getNames();
- * INameEntity name = (INameEntity)LocalizationUtils.getLocalizedElement(names.toArray(new INameEntity[fNamesList.size()]), new String[]{"en"});
+ * List<IName> names = widget.getNames();
+ * IName name = (IName)LocalizationUtils.getLocalizedElement(names.toArray(new IName[fNamesList.size()]), new String[]{"en"});
* </code>
*
* @param locale
@@ -108,6 +108,6 @@ public interface W3CWidget extends ILoca
/**
* @return the update description document URL for the widget, or null if no valid update URL has been set
*/
- public String getUpdate();
+ public String getUpdateLocation();
}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java Tue Jun 12 12:38:28 2012
@@ -93,7 +93,7 @@ public class W3CWidgetFactory {
this.outputDirectory = null;
this.encodings = new String[]{"UTF-8"};
this.startPageProcessor = new IStartPageProcessor(){
- public void processStartFile(File startFile, W3CWidget model,IContentEntity content)
+ public void processStartFile(File startFile, W3CWidget model,IContent content)
throws Exception {
}
@@ -276,7 +276,7 @@ public class W3CWidgetFactory {
WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory);
// Iterate over all start files and update paths
- for (IContentEntity content: widgetModel.getContentList()){
+ for (IContent content: widgetModel.getContentList()){
// now update the js links in the start page
File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AbstractLocalizedEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AbstractLocalizedEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AbstractLocalizedEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AbstractLocalizedEntity.java Tue Jun 12 12:38:28 2012
@@ -14,10 +14,12 @@
package org.apache.wookie.w3c.impl;
import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.wookie.w3c.ILocalizedEntity;
+import org.apache.wookie.w3c.IDirectional;
+import org.apache.wookie.w3c.ILocalized;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.LocalizationUtils;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jdom.Namespace;
@@ -28,7 +30,7 @@ import org.jdom.Text;
* utility methods for extracting and processing text that uses language tags
* and text direction (e.g. RTL)
*/
-public abstract class AbstractLocalizedEntity implements ILocalizedEntity {
+public abstract class AbstractLocalizedEntity implements ILocalized, IDirectional, IElement {
/**
* a Language string conforming to BCP47
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AccessEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AccessEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AccessEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AccessEntity.java Tue Jun 12 12:38:28 2012
@@ -19,16 +19,17 @@ import java.net.URI;
import java.net.URL;
import java.util.Arrays;
-import org.apache.wookie.w3c.IAccessEntity;
+import org.apache.wookie.w3c.IAccess;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.IRIValidator;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Attribute;
import org.jdom.Element;
/**
* The Access element is defined in: http://www.w3.org/TR/widgets-access/
*/
-public class AccessEntity implements IAccessEntity {
+public class AccessEntity implements IAccess, IElement {
private String fOrigin;
private boolean fSubDomains;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AuthorEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AuthorEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AuthorEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/AuthorEntity.java Tue Jun 12 12:38:28 2012
@@ -14,16 +14,17 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.IAuthorEntity;
+import org.apache.wookie.w3c.IAuthor;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.IRIValidator;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* The <author> element
*/
-public class AuthorEntity extends AbstractLocalizedEntity implements IAuthorEntity {
+public class AuthorEntity extends AbstractLocalizedEntity implements IAuthor, IElement {
private String fAuthorName;
private String fHref;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ContentEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ContentEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ContentEntity.java Tue Jun 12 12:38:28 2012
@@ -16,12 +16,12 @@ package org.apache.wookie.w3c.impl;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.lang.StringUtils;
-import org.apache.wookie.w3c.IContentEntity;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.exceptions.InvalidContentTypeException;
import org.apache.wookie.w3c.util.UnicodeUtils;
import org.apache.wookie.w3c.util.WidgetPackageUtils;
+import org.apache.wookie.w3c.xml.IContentEntity;
import org.jdom.Element;
/**
* @author Paul Sharples
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/DescriptionEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/DescriptionEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/DescriptionEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/DescriptionEntity.java Tue Jun 12 12:38:28 2012
@@ -14,13 +14,14 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.IDescriptionEntity;
+import org.apache.wookie.w3c.IDescription;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* The <description> element
*/
-public class DescriptionEntity extends AbstractLocalizedEntity implements IDescriptionEntity {
+public class DescriptionEntity extends AbstractLocalizedEntity implements IDescription, IElement {
private String fDescription;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/FeatureEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/FeatureEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/FeatureEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/FeatureEntity.java Tue Jun 12 12:38:28 2012
@@ -17,33 +17,34 @@ package org.apache.wookie.w3c.impl;
import java.util.ArrayList;
import java.util.List;
-import org.apache.wookie.w3c.IFeatureEntity;
-import org.apache.wookie.w3c.IParamEntity;
+import org.apache.wookie.w3c.IFeature;
+import org.apache.wookie.w3c.IParam;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.util.IRIValidator;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* @author Paul Sharples
* @version $Id: FeatureEntity.java,v 1.3 2009-09-02 18:37:31 scottwilson Exp $
*/
-public class FeatureEntity implements IFeatureEntity {
+public class FeatureEntity implements IFeature, IElement {
private String fName;
private boolean fRequired;
- private List<IParamEntity> fParams;
+ private List<IParam> fParams;
private String[] features; // the set of platform-supported features
public FeatureEntity(String[] features){
fName = "";
fRequired = false;
- fParams = new ArrayList<IParamEntity>();
+ fParams = new ArrayList<IParam>();
this.features = features;
}
public FeatureEntity(String name, boolean required,
- List<IParamEntity> params) {
+ List<IParam> params) {
super();
fName = name;
fRequired = required;
@@ -54,7 +55,7 @@ public class FeatureEntity implements IF
super();
fName = name;
fRequired = required;
- fParams = new ArrayList<IParamEntity>();
+ fParams = new ArrayList<IParam>();
}
public boolean hasParams(){
@@ -80,11 +81,11 @@ public class FeatureEntity implements IF
fRequired = required;
}
- public List<IParamEntity> getParameters() {
+ public List<IParam> getParameters() {
return fParams;
}
- public void setParameters(List<IParamEntity> params) {
+ public void setParameters(List<IParam> params) {
fParams = params;
}
@@ -128,7 +129,7 @@ public class FeatureEntity implements IF
// PARAM optional, can be 0 or many
if(tag.equals(IW3CXMLConfiguration.PARAM_ELEMENT)) {
- IParamEntity aParam = new ParamEntity();
+ ParamEntity aParam = new ParamEntity();
aParam.fromXML(child);
if (aParam.getName()!=null && aParam.getValue()!=null) fParams.add(aParam);
}
@@ -140,8 +141,8 @@ public class FeatureEntity implements IF
Element element = new Element(IW3CXMLConfiguration.FEATURE_ELEMENT, IW3CXMLConfiguration.MANIFEST_NAMESPACE);
element.setAttribute(IW3CXMLConfiguration.NAME_ATTRIBUTE, getName());
element.setAttribute(IW3CXMLConfiguration.REQUIRED_ATTRIBUTE, String.valueOf(isRequired()));
- for (IParamEntity param: getParameters()){
- element.addContent(param.toXml());
+ for (IParam param: getParameters()){
+ element.addContent(((IElement) param).toXml());
}
return element;
}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/IconEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/IconEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/IconEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/IconEntity.java Tue Jun 12 12:38:28 2012
@@ -15,19 +15,20 @@
package org.apache.wookie.w3c.impl;
import org.apache.commons.compress.archivers.zip.ZipFile;
-import org.apache.wookie.w3c.IIconEntity;
+import org.apache.wookie.w3c.IIcon;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.util.ContentTypeUtils;
import org.apache.wookie.w3c.util.NumberUtils;
import org.apache.wookie.w3c.util.UnicodeUtils;
import org.apache.wookie.w3c.util.WidgetPackageUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* @author Paul Sharples
* @version $Id: IconEntity.java,v 1.3 2009-09-02 18:37:31 scottwilson Exp $
*/
-public class IconEntity extends AbstractLocalizedEntity implements IIconEntity{
+public class IconEntity extends AbstractLocalizedEntity implements IIcon, IElement{
private String fSrc;
private Integer fHeight;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/LicenseEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/LicenseEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/LicenseEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/LicenseEntity.java Tue Jun 12 12:38:28 2012
@@ -14,15 +14,16 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.ILicenseEntity;
+import org.apache.wookie.w3c.ILicense;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* the <license> element
*/
-public class LicenseEntity extends AbstractLocalizedEntity implements ILicenseEntity {
+public class LicenseEntity extends AbstractLocalizedEntity implements ILicense, IElement {
private String fLicenseText;
private String fHref;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/NameEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/NameEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/NameEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/NameEntity.java Tue Jun 12 12:38:28 2012
@@ -14,15 +14,16 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.INameEntity;
+import org.apache.wookie.w3c.IName;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* the <name> element
*/
-public class NameEntity extends AbstractLocalizedEntity implements INameEntity {
+public class NameEntity extends AbstractLocalizedEntity implements IName, IElement {
private String fName;
private String fShort;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ParamEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ParamEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ParamEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/ParamEntity.java Tue Jun 12 12:38:28 2012
@@ -14,16 +14,17 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.IParamEntity;
+import org.apache.wookie.w3c.IParam;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* @author Paul Sharples
* @version $Id: ParamEntity.java,v 1.3 2009-09-02 18:37:31 scottwilson Exp $
*/
-public class ParamEntity implements IParamEntity {
+public class ParamEntity implements IParam, IElement {
private String fName;
private String fValue;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/PreferenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/PreferenceEntity.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/PreferenceEntity.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/PreferenceEntity.java Tue Jun 12 12:38:28 2012
@@ -14,16 +14,17 @@
package org.apache.wookie.w3c.impl;
-import org.apache.wookie.w3c.IPreferenceEntity;
+import org.apache.wookie.w3c.IPreference;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.util.UnicodeUtils;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
/**
* @author Paul Sharples
* @version $Id: PreferenceEntity.java,v 1.3 2009-09-02 18:37:31 scottwilson Exp $
*/
-public class PreferenceEntity extends ParamEntity implements IPreferenceEntity {
+public class PreferenceEntity extends ParamEntity implements IPreference, IElement {
private boolean fReadOnly;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java Tue Jun 12 12:38:28 2012
@@ -25,24 +25,26 @@ import org.apache.commons.lang.StringUti
import org.apache.log4j.Logger;
import org.apache.wookie.w3c.updates.UpdateDescription;
import org.apache.wookie.w3c.util.LocalizationUtils;
-import org.apache.wookie.w3c.IAccessEntity;
-import org.apache.wookie.w3c.IAuthorEntity;
-import org.apache.wookie.w3c.IContentEntity;
-import org.apache.wookie.w3c.IDescriptionEntity;
-import org.apache.wookie.w3c.IFeatureEntity;
-import org.apache.wookie.w3c.IIconEntity;
-import org.apache.wookie.w3c.ILicenseEntity;
-import org.apache.wookie.w3c.ILocalizedEntity;
-import org.apache.wookie.w3c.W3CWidget;
-import org.apache.wookie.w3c.INameEntity;
-import org.apache.wookie.w3c.IPreferenceEntity;
+import org.apache.wookie.w3c.IAccess;
+import org.apache.wookie.w3c.IAuthor;
+import org.apache.wookie.w3c.IContent;
+import org.apache.wookie.w3c.IDescription;
+import org.apache.wookie.w3c.IFeature;
+import org.apache.wookie.w3c.IIcon;
+import org.apache.wookie.w3c.ILicense;
+import org.apache.wookie.w3c.ILocalized;
+import org.apache.wookie.w3c.IName;
+import org.apache.wookie.w3c.IPreference;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
+import org.apache.wookie.w3c.W3CWidget;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.util.IRIValidator;
import org.apache.wookie.w3c.util.NumberUtils;
import org.apache.wookie.w3c.util.RandomGUID;
import org.apache.wookie.w3c.util.UnicodeUtils;
import org.apache.wookie.w3c.util.WidgetPackageUtils;
+import org.apache.wookie.w3c.xml.IContentEntity;
+import org.apache.wookie.w3c.xml.IElement;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
@@ -51,7 +53,7 @@ import org.jdom.input.SAXBuilder;
* for a widget, including all sub-objects
* @author Paul Sharples
*/
-public class WidgetManifestModel extends AbstractLocalizedEntity implements W3CWidget {
+public class WidgetManifestModel extends AbstractLocalizedEntity implements W3CWidget, IElement {
static Logger fLogger = Logger.getLogger(WidgetManifestModel.class.getName());
@@ -63,15 +65,15 @@ public class WidgetManifestModel extends
private Integer fWidth;
private String fViewModes;
private String[] features;
- private List<INameEntity> fNamesList;
- private List<IDescriptionEntity> fDescriptionsList;
- private IAuthorEntity fAuthor;
- private List<ILicenseEntity> fLicensesList;
- private List<IIconEntity> fIconsList;
- private List<IAccessEntity> fAccessList;
- private List<IContentEntity> fContentList;
- private List<IFeatureEntity> fFeaturesList;
- private List<IPreferenceEntity> fPreferencesList;
+ private List<IName> fNamesList;
+ private List<IDescription> fDescriptionsList;
+ private IAuthor fAuthor;
+ private List<ILicense> fLicensesList;
+ private List<IIcon> fIconsList;
+ private List<IAccess> fAccessList;
+ private List<IContent> fContentList;
+ private List<IFeature> fFeaturesList;
+ private List<IPreference> fPreferencesList;
private String fUpdate;
private String[] supportedEncodings;
@@ -90,14 +92,14 @@ public class WidgetManifestModel extends
this.zip = zip;
this.features = features;
this.supportedEncodings = encodings;
- fNamesList = new ArrayList<INameEntity>();
- fDescriptionsList = new ArrayList<IDescriptionEntity>();
- fLicensesList = new ArrayList<ILicenseEntity>();
- fIconsList = new ArrayList<IIconEntity>();
- fContentList = new ArrayList<IContentEntity>();
- fAccessList = new ArrayList<IAccessEntity>();
- fFeaturesList = new ArrayList<IFeatureEntity>();
- fPreferencesList = new ArrayList<IPreferenceEntity>();
+ fNamesList = new ArrayList<IName>();
+ fDescriptionsList = new ArrayList<IDescription>();
+ fLicensesList = new ArrayList<ILicense>();
+ fIconsList = new ArrayList<IIcon>();
+ fContentList = new ArrayList<IContent>();
+ fAccessList = new ArrayList<IAccess>();
+ fFeaturesList = new ArrayList<IFeature>();
+ fPreferencesList = new ArrayList<IPreference>();
this.defaultIdentifier = defaultIdentifier;
SAXBuilder builder = new SAXBuilder();
Element root;
@@ -113,7 +115,7 @@ public class WidgetManifestModel extends
if (iconpath != null) {
// don't add it if its a duplicate
boolean exists = false;
- for (IIconEntity icon: fIconsList){
+ for (IIcon icon: fIconsList){
if (icon.getSrc().equals(iconpath)) exists = true;
}
if (!exists){
@@ -130,7 +132,7 @@ public class WidgetManifestModel extends
if (startpath != null) {
// don't add it if its a duplicate
boolean exists = false;
- for (IContentEntity content: fContentList){
+ for (IContent content: fContentList){
if (content.getSrc().equals(startpath)) exists = true;
}
if (!exists){
@@ -160,39 +162,39 @@ public class WidgetManifestModel extends
return fVersion;
}
- public List<IPreferenceEntity> getPrefences(){
+ public List<IPreference> getPreferences(){
return fPreferencesList;
}
- public List<IFeatureEntity> getFeatures(){
+ public List<IFeature> getFeatures(){
return fFeaturesList;
}
- public List<IAccessEntity> getAccessList(){
+ public List<IAccess> getAccessList(){
return fAccessList;
}
- public IAuthorEntity getAuthor(){
+ public IAuthor getAuthor(){
return fAuthor;
}
- public List<IContentEntity> getContentList() {
+ public List<IContent> getContentList() {
return fContentList;
}
- public List<IDescriptionEntity> getDescriptions(){
+ public List<IDescription> getDescriptions(){
return fDescriptionsList;
}
- public List<INameEntity> getNames() {
+ public List<IName> getNames() {
return fNamesList;
}
- public List<IIconEntity> getIconsList() {
+ public List<IIcon> getIcons() {
return fIconsList;
}
- public List<ILicenseEntity> getLicensesList() {
+ public List<ILicense> getLicenses() {
return fLicensesList;
}
@@ -208,7 +210,7 @@ public class WidgetManifestModel extends
return fWidth;
}
- public String getUpdate(){
+ public String getUpdateLocation(){
return fUpdate;
}
@@ -222,13 +224,13 @@ public class WidgetManifestModel extends
}
public String getLocalName(String locale){
- INameEntity name = (INameEntity)LocalizationUtils.getLocalizedElement(fNamesList.toArray(new INameEntity[fNamesList.size()]), new String[]{locale}, defaultLocale);
+ NameEntity name = (NameEntity)LocalizationUtils.getLocalizedElement(fNamesList.toArray(new NameEntity[fNamesList.size()]), new String[]{locale}, defaultLocale);
if (name != null) return name.getName();
return IW3CXMLConfiguration.UNKNOWN;
}
public void updateIconPaths(String path){
- for(IIconEntity icon : fIconsList){
+ for(IIcon icon : fIconsList){
if(!icon.getSrc().startsWith("http:")) icon.setSrc(path + icon.getSrc());
}
}
@@ -316,7 +318,7 @@ public class WidgetManifestModel extends
// NAME IS OPTIONAL - get the name elements (multiple based on xml:lang)
if(tag.equals(IW3CXMLConfiguration.NAME_ELEMENT)) {
- INameEntity aName = new NameEntity();
+ NameEntity aName = new NameEntity();
aName.fromXML(child);
// add it to our list only if its not a repetition of an
// existing name for the locale
@@ -325,7 +327,7 @@ public class WidgetManifestModel extends
// DESCRIPTION IS OPTIONAL multiple on xml:lang
if(tag.equals(IW3CXMLConfiguration.DESCRIPTION_ELEMENT)) {
- IDescriptionEntity aDescription = new DescriptionEntity();
+ DescriptionEntity aDescription = new DescriptionEntity();
aDescription.fromXML(child);
// add it to our list only if its not a repetition of an
// existing description for the locale and the language tag is valid
@@ -335,7 +337,7 @@ public class WidgetManifestModel extends
// AUTHOR IS OPTIONAL - can only be one, ignore subsequent repetitions
if(tag.equals(IW3CXMLConfiguration.AUTHOR_ELEMENT) && fAuthor == null) {
fAuthor = new AuthorEntity();
- fAuthor.fromXML(child);
+ ((IElement) fAuthor).fromXML(child);
}
// UDPATE DESCRIPTION IS OPTONAL - can only be one, ignore subsequent repetitions
@@ -348,7 +350,7 @@ public class WidgetManifestModel extends
// LICENSE IS OPTIONAL - can be many
if(tag.equals(IW3CXMLConfiguration.LICENSE_ELEMENT)) {
- ILicenseEntity aLicense = new LicenseEntity();
+ LicenseEntity aLicense = new LicenseEntity();
aLicense.fromXML(child);
// add it to our list only if its not a repetition of an
// existing entry for the locale and the language tag is valid
@@ -357,15 +359,15 @@ public class WidgetManifestModel extends
// ICON IS OPTIONAL - can be many
if(tag.equals(IW3CXMLConfiguration.ICON_ELEMENT)) {
- IIconEntity anIcon = new IconEntity();
+ IconEntity anIcon = new IconEntity();
anIcon.fromXML(child,locales,zip);
if (anIcon.getSrc()!=null) fIconsList.add(anIcon);
}
// ACCESS IS OPTIONAL can be many
if(tag.equals(IW3CXMLConfiguration.ACCESS_ELEMENT)) {
- IAccessEntity access = new AccessEntity();
- access.fromXML(child);
+ IAccess access = new AccessEntity();
+ ((IElement) access).fromXML(child);
if (access.getOrigin()!=null){
if (access.getOrigin().equals("*")) {
fAccessList.add(0, access);
@@ -387,20 +389,20 @@ public class WidgetManifestModel extends
// FEATURE IS OPTIONAL - can be many
if(tag.equals(IW3CXMLConfiguration.FEATURE_ELEMENT)) {
- IFeatureEntity feature = new FeatureEntity(this.features);
+ FeatureEntity feature = new FeatureEntity(this.features);
feature.fromXML(child);
if (feature.getName()!=null) fFeaturesList.add(feature);
}
// PREFERENCE IS OPTIONAL - can be many
if(tag.equals(IW3CXMLConfiguration.PREFERENCE_ELEMENT)) {
- IPreferenceEntity preference = new PreferenceEntity();
+ PreferenceEntity preference = new PreferenceEntity();
preference.fromXML(child);
// Skip preferences without names
if (preference.getName() != null){
// Skip preferences already defined
boolean found = false;
- for (IPreferenceEntity pref:getPrefences()){
+ for (IPreference pref:getPreferences()){
if (pref.getName().equals(preference.getName())) found = true;
}
if (!found) fPreferencesList.add(preference);
@@ -419,9 +421,9 @@ public class WidgetManifestModel extends
* @return true if the list contains an entity with matching language
*/
@SuppressWarnings("unchecked")
- private boolean isFirstLocalizedEntity(List list, ILocalizedEntity ent){
+ private boolean isFirstLocalizedEntity(List list, ILocalized ent){
boolean first = true;
- for (ILocalizedEntity entity: (ILocalizedEntity[])list.toArray(new ILocalizedEntity[list.size()]))
+ for (ILocalized entity: (ILocalized[])list.toArray(new ILocalized[list.size()]))
if (StringUtils.equals(entity.getLang(), ent.getLang())) first = false;
return first;
}
@@ -458,54 +460,54 @@ public class WidgetManifestModel extends
// Name
- for (INameEntity name: getNames()){
- Element nameElem = name.toXml();
+ for (IName name: getNames()){
+ Element nameElem = ((IElement) name).toXml();
widgetElem.addContent(nameElem);
}
// Description
- for (IDescriptionEntity description: getDescriptions()){
- widgetElem.addContent(description.toXml());
+ for (IDescription description: getDescriptions()){
+ widgetElem.addContent(((IElement) description).toXml());
}
// Author
- if (getAuthor() != null) widgetElem.addContent(getAuthor().toXml());
+ if (getAuthor() != null) widgetElem.addContent(((IElement) getAuthor()).toXml());
// Update
- if (getUpdate()!= null){
- widgetElem.addContent(new UpdateDescription(getUpdate()).toXML());
+ if (getUpdateLocation()!= null){
+ widgetElem.addContent(new UpdateDescription(getUpdateLocation()).toXML());
}
// Licenses
- for (ILicenseEntity license: getLicensesList()){
- widgetElem.addContent(license.toXml());
+ for (ILicense license: getLicenses()){
+ widgetElem.addContent(((IElement) license).toXml());
}
// Icons
- for (IIconEntity icon:getIconsList()){
- Element iconElem = icon.toXml();
+ for (IIcon icon:getIcons()){
+ Element iconElem = ((IElement) icon).toXml();
widgetElem.addContent(iconElem);
}
// Access
- for (IAccessEntity access: getAccessList()){
- Element accessElem = access.toXml();
+ for (IAccess access: getAccessList()){
+ Element accessElem = ((IElement) access).toXml();
widgetElem.addContent(accessElem);
}
// Content
- for (IContentEntity content: getContentList()){
- Element contentElem = content.toXml();
+ for (IContent content: getContentList()){
+ Element contentElem = ((IElement) content).toXml();
widgetElem.addContent(contentElem);
}
// Features
- for (IFeatureEntity feature: getFeatures()){
- widgetElem.addContent(feature.toXml());
+ for (IFeature feature: getFeatures()){
+ widgetElem.addContent(((IElement) feature).toXml());
}
// Preferences
- for (IPreferenceEntity preference: getPrefences()){
- widgetElem.addContent(preference.toXml());
+ for (IPreference preference: getPreferences()){
+ widgetElem.addContent(((IElement) preference).toXml());
}
return widgetElem;
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateUtils.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateUtils.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateUtils.java Tue Jun 12 12:38:28 2012
@@ -15,11 +15,11 @@ package org.apache.wookie.w3c.updates;
import java.io.IOException;
-import org.apache.wookie.w3c.W3CWidget;
import org.apache.wookie.w3c.W3CWidgetFactory;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.exceptions.BadWidgetZipFileException;
import org.apache.wookie.w3c.exceptions.InvalidContentTypeException;
+import org.apache.wookie.w3c.W3CWidget;
/**
* Utility methods for working with updates
@@ -33,7 +33,7 @@ public class UpdateUtils {
* @return an UpdateDescriptionDocument for an update to the widget, or null if there is no update available
*/
public static UpdateDescriptionDocument checkForUpdate(W3CWidget widget){
- return checkForUpdate(widget.getUpdate(), widget.getVersion());
+ return checkForUpdate(widget.getUpdateLocation(), widget.getVersion());
}
/**
@@ -64,7 +64,7 @@ public class UpdateUtils {
*/
public static W3CWidget getUpdate(W3CWidgetFactory factory, W3CWidget widget){
try {
- return getUpdate(factory, widget.getIdentifier(), widget.getUpdate(), widget.getVersion(), false);
+ return getUpdate(factory, widget.getIdentifier(), widget.getUpdateLocation(), widget.getVersion(), false);
} catch (Exception e) {
return null;
}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java Tue Jun 12 12:38:28 2012
@@ -13,11 +13,7 @@
*/
package org.apache.wookie.w3c.util;
-import org.apache.wookie.w3c.IAuthorEntity;
-import org.apache.wookie.w3c.IDescriptionEntity;
-import org.apache.wookie.w3c.ILicenseEntity;
-import org.apache.wookie.w3c.INameEntity;
-import org.apache.wookie.w3c.W3CWidget;
+import org.apache.wookie.w3c.*;
/**
* i18n formatting utilities
@@ -48,7 +44,7 @@ public class FormattingUtils {
* @param name the Widget's Name entity
* @return a CSS-formatted i18n string
*/
- public static String getFormattedWidgetName(INameEntity name){
+ public static String getFormattedWidgetName(IName name){
return getFormatted(name.getDir(), name.getName());
}
/**
@@ -56,7 +52,7 @@ public class FormattingUtils {
* @param name the Widget's Name entity
* @return a CSS-formatted i18n string
*/
- public static String getFormattedWidgetShortName(INameEntity name){
+ public static String getFormattedWidgetShortName(IName name){
return getFormatted(name.getDir(), name.getShort());
}
/**
@@ -72,7 +68,7 @@ public class FormattingUtils {
* @param description the Widget's description entity
* @return a CSS-formatted i18n string
*/
- public static String getFormattedWidgetDescription(IDescriptionEntity description){
+ public static String getFormattedWidgetDescription(IDescription description){
return getFormatted(description.getDir(), description.getDescription());
}
/**
@@ -80,7 +76,7 @@ public class FormattingUtils {
* @param author the Widget's author entity
* @return a CSS-formatted i18n string
*/
- public static String getFormattedWidgetAuthor(IAuthorEntity author){
+ public static String getFormattedWidgetAuthor(IAuthor author){
return getFormatted(author.getDir(), author.getAuthorName());
}
/**
@@ -88,7 +84,7 @@ public class FormattingUtils {
* @param license the Widget's License entity
* @return a CSS-formatted i18n string
*/
- public static String getFormattedWidgetLicense(ILicenseEntity license){
+ public static String getFormattedWidgetLicense(ILicense license){
return getFormatted(license.getDir(), license.getLicenseText());
}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java Tue Jun 12 12:38:28 2012
@@ -20,7 +20,7 @@ import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
-import org.apache.wookie.w3c.ILocalizedElement;
+import org.apache.wookie.w3c.ILocalized;
import com.ibm.icu.util.GlobalizationPreferences;
import com.ibm.icu.util.ULocale;
@@ -42,11 +42,11 @@ public class LocalizationUtils {
* @param defaultLocale the default locale in case none of the supplied locales provide a match
* @return an ILocalizedElement, or null if there are no valid entries
*/
- public static ILocalizedElement getLocalizedElement(ILocalizedElement[] elements, String[] locales, String defaultLocale){
- ILocalizedElement element = getLocalizedElement(elements, locales);
+ public static ILocalized getLocalizedElement(ILocalized[] elements, String[] locales, String defaultLocale){
+ ILocalized element = getLocalizedElement(elements, locales);
// If using the algorithm did not return ANY results, try again using defaultlocale
if (element == null && elements != null){
- for(ILocalizedElement elem:elements){
+ for(ILocalized elem:elements){
if (elem.getLang().equals(defaultLocale)) return elem;
}
}
@@ -60,7 +60,7 @@ public class LocalizationUtils {
* @param locales
* @return an ILocalizedElement, or null if there are no valid entries
*/
- protected static ILocalizedElement getLocalizedElement(ILocalizedElement[] elements,String[] locales){
+ protected static ILocalized getLocalizedElement(ILocalized[] elements,String[] locales){
if (elements == null) return null;
elements = processElementsByLocales(elements,locales);
if (elements.length == 0) return null;
@@ -78,13 +78,13 @@ public class LocalizationUtils {
* @param defaultLocale the default locale in case none of the supplied locales provide a match
* @return the sorted and filtered set of elements
*/
- public static ILocalizedElement[] processElementsByLocales(ILocalizedElement[] elements,String[] locales, String defaultLocale){
+ public static ILocalized[] processElementsByLocales(ILocalized[] elements,String[] locales, String defaultLocale){
if (elements == null) return null;
- ILocalizedElement[] filteredElements = processElementsByLocales(elements,locales);
+ ILocalized[] filteredElements = processElementsByLocales(elements,locales);
if (filteredElements == null || filteredElements.length == 0){
- for (ILocalizedElement element: elements){
+ for (ILocalized element: elements){
if(element.getLang().equals(defaultLocale)){
- return (ILocalizedElement[]) ArrayUtils.removeElement(elements, element);
+ return (ILocalized[]) ArrayUtils.removeElement(elements, element);
}
}
}
@@ -100,7 +100,7 @@ public class LocalizationUtils {
* @param locales
* @return the sorted and filtered set of elements
*/
- protected static ILocalizedElement[] processElementsByLocales(ILocalizedElement[] elements,String[] locales){
+ protected static ILocalized[] processElementsByLocales(ILocalized[] elements,String[] locales){
if (elements == null) return null;
List<ULocale> localesList = getProcessedLocaleList(locales);
Arrays.sort(elements, new LocaleComparator(localesList));
@@ -112,7 +112,7 @@ public class LocalizationUtils {
* any localized elements first, then any unlocalized elements
* @return the sorted list of elements
*/
- public static ILocalizedElement[] processElementsByDefaultLocales(ILocalizedElement[] elements){
+ public static ILocalized[] processElementsByDefaultLocales(ILocalized[] elements){
if (elements == null) return null;
List<ULocale> localesList = getDefaultLocaleList();
Arrays.sort(elements, new LocaleComparator(localesList));
@@ -123,12 +123,12 @@ public class LocalizationUtils {
* Comparator that sorts elements based on priority in the given locale list,
* with the assumption that earlier in the list means a higher priority.
*/
- static class LocaleComparator implements Comparator<ILocalizedElement>{
+ static class LocaleComparator implements Comparator<ILocalized>{
private List<ULocale> locales;
public LocaleComparator(List<ULocale> locales){
this.locales = locales;
}
- public int compare(ILocalizedElement o1, ILocalizedElement o2) {
+ public int compare(ILocalized o1, ILocalized o2) {
// check non-localized values for comparison
if (o1.getLang()!=null && o2.getLang() == null) return -1;
if (o1.getLang()==null && o2.getLang()!= null) return 1;
@@ -158,20 +158,20 @@ public class LocalizationUtils {
* @param locales
* @return a copy of the array of elements only containing the filtered elements
*/
- protected static ILocalizedElement[] filter(ILocalizedElement[] elements, List<ULocale> locales){
- for (ILocalizedElement element:elements){
+ protected static ILocalized[] filter(ILocalized[] elements, List<ULocale> locales){
+ for (ILocalized element:elements){
String lang = element.getLang();
boolean found = false;
for(ULocale locale:locales){
if (locale.toLanguageTag().equalsIgnoreCase(lang)) found = true;
}
- if (!found && lang != null) elements = (ILocalizedElement[])ArrayUtils.removeElement(elements, element);
+ if (!found && lang != null) elements = (ILocalized[])ArrayUtils.removeElement(elements, element);
}
// Strip out non-localized elements only if there are localized elements left
if (elements.length > 0){
if (elements[0].getLang() != null){
- for (ILocalizedElement element:elements){
- if (element.getLang()==null) elements = (ILocalizedElement[])ArrayUtils.removeElement(elements, element);
+ for (ILocalized element:elements){
+ if (element.getLang()==null) elements = (ILocalized[])ArrayUtils.removeElement(elements, element);
}
}
}
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/WidgetOutputter.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/WidgetOutputter.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/WidgetOutputter.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/WidgetOutputter.java Tue Jun 12 12:38:28 2012
@@ -17,8 +17,9 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.apache.wookie.w3c.IContentEntity;
-import org.apache.wookie.w3c.IIconEntity;
+import org.apache.wookie.w3c.IContent;
+import org.apache.wookie.w3c.IIcon;
+import org.apache.wookie.w3c.xml.IElement;
import org.apache.wookie.w3c.W3CWidget;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
@@ -79,7 +80,7 @@ public class WidgetOutputter {
*/
private Document createWidgetDocument(W3CWidget widget){
widget = replacePaths(widget);
- return new Document(widget.toXml());
+ return new Document(((IElement) widget).toXml());
}
/**
@@ -98,14 +99,14 @@ public class WidgetOutputter {
W3CWidget localWidget = widget;
// Replace Content Src attributes
- for (IContentEntity content:localWidget.getContentList()){
+ for (IContent content:localWidget.getContentList()){
String src = content.getSrc();
src = src.replace(installedPath, "");
content.setSrc(src);
}
// Replace Icon Src attributes
- for (IIconEntity icon:localWidget.getIconsList()){
+ for (IIcon icon:localWidget.getIcons()){
String src = icon.getSrc();
src = src.replace(installedPath, "");
icon.setSrc(src);
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IContentEntity.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IContentEntity.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IContentEntity.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c.xml;
+
+import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.wookie.w3c.IContent;
+import org.apache.wookie.w3c.exceptions.BadManifestException;
+import org.jdom.Element;
+
+/**
+ * A Widget Start Page
+ */
+public interface IContentEntity extends IContent, IElement {
+
+ public void fromXML(Element element, String[] locales, String[] encodings, ZipFile zip) throws BadManifestException;
+
+}
+
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IElement.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IElement.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IElement.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IElement.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,41 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c.xml;
+
+import org.apache.wookie.w3c.exceptions.BadManifestException;
+import org.jdom.Element;
+
+/**
+ * Base class for model objects that are unmarshalled from an XML element
+ */
+public interface IElement {
+
+ /**
+ * Unmarshall the given XML Element to this Object
+ *
+ * @param element The Element to unmarshall
+ */
+ void fromXML(Element element) throws BadManifestException;
+
+ /**
+ * Marshall the entity into an XML Element
+ * @return the W3C Widgets Element representing the content of the entity
+ */
+ Element toXml();
+
+}
Added: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IIconEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IIconEntity.java?rev=1349299&view=auto
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IIconEntity.java (added)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/xml/IIconEntity.java Tue Jun 12 12:38:28 2012
@@ -0,0 +1,32 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.w3c.xml;
+
+import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.wookie.w3c.IIcon;
+import org.apache.wookie.w3c.exceptions.BadManifestException;
+import org.jdom.Element;
+
+/**
+ * a widget icon
+ */
+public interface IIconEntity extends IIcon, IElement{
+
+ public void fromXML(Element element, String[] locales, ZipFile zip) throws BadManifestException;
+
+}
Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/OpenSocialUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/OpenSocialUtilsTest.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/OpenSocialUtilsTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/OpenSocialUtilsTest.java Tue Jun 12 12:38:28 2012
@@ -17,13 +17,13 @@ package org.apache.wookie.tests;
import static org.junit.Assert.*;
import org.apache.wookie.Messages;
-import org.apache.wookie.beans.IStartFile;
import org.apache.wookie.beans.IWidget;
import org.apache.wookie.beans.IWidgetInstance;
import org.apache.wookie.beans.jpa.impl.StartFileImpl;
import org.apache.wookie.beans.jpa.impl.WidgetImpl;
import org.apache.wookie.beans.jpa.impl.WidgetInstanceImpl;
import org.apache.wookie.util.opensocial.OpenSocialUtils;
+import org.apache.wookie.w3c.IContent;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,11 +38,11 @@ public class OpenSocialUtilsTest{
@BeforeClass
public static void setUp(){
IWidget widget = new WidgetImpl();
- widget.setGuid("http://getwookie.org/test");
- IStartFile startFile = new StartFileImpl();
- startFile.setUrl("http://getwookie.org/test/index.html");
+ widget.setIdentifier("http://getwookie.org/test");
+ IContent startFile = new StartFileImpl();
+ startFile.setSrc("http://getwookie.org/test/index.html");
startFile.setLang("en");
- widget.getStartFiles().add(startFile);
+ widget.getContentList().add(startFile);
INSTANCE = new WidgetInstanceImpl();
INSTANCE.setWidget(widget);
Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/beans/AbstractPersistenceTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/beans/AbstractPersistenceTest.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/beans/AbstractPersistenceTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/beans/AbstractPersistenceTest.java Tue Jun 12 12:38:28 2012
@@ -88,7 +88,7 @@ public abstract class AbstractPersistenc
//
// test findByValue method for IWidget
//
- String widgetGuid = allWidgets[0].getGuid();
+ String widgetGuid = allWidgets[0].getIdentifier();
IWidget [] widgetsByValue = persistenceManager.findByValue(IWidget.class, "guid", widgetGuid);
assertNotNull(widgetsByValue);
assertEquals(1, widgetsByValue.length);
@@ -137,7 +137,7 @@ public abstract class AbstractPersistenc
String apiKey = "TEST";
IWidget [] widgets = persistenceManager.findAll(IWidget.class);
IWidget widget = widgets[0];
- widgetGuid = widget.getGuid();
+ widgetGuid = widget.getIdentifier();
//
// check that the Widget Instance does not yet exist
@@ -202,7 +202,7 @@ public abstract class AbstractPersistenc
widget = widgets[0];
IWidgetInstance widgetInstance0 = persistenceManager.findWidgetInstanceByGuid(apiKey, "test", "test-shared-data-key", widgetGuid);
assertNotNull(widgetInstance0);
- widgetGuid = widget.getGuid();
+ widgetGuid = widget.getIdentifier();
//
// Get the widget instance created in the previous transaction via "widget GUID"
Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/flatpack/FlatpackFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/flatpack/FlatpackFactoryTest.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/flatpack/FlatpackFactoryTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/flatpack/FlatpackFactoryTest.java Tue Jun 12 12:38:28 2012
@@ -25,8 +25,8 @@ import org.apache.wookie.beans.IPreferen
import org.apache.wookie.beans.IWidgetInstance;
import org.apache.wookie.feature.Features;
import org.apache.wookie.flatpack.FlatpackFactory;
-import org.apache.wookie.w3c.W3CWidget;
import org.apache.wookie.w3c.W3CWidgetFactory;
+import org.apache.wookie.w3c.W3CWidget;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -247,8 +247,8 @@ public class FlatpackFactoryTest {
//
System.out.println(file.getAbsolutePath());
W3CWidget fpWidget = fac.parse(file);
- assertEquals("hiScore", fpWidget.getPrefences().get(0).getName());
- assertEquals("1000", fpWidget.getPrefences().get(0).getValue());
+ assertEquals("hiScore", fpWidget.getPreferences().get(0).getName());
+ assertEquals("1000", fpWidget.getPreferences().get(0).getValue());
}
@@ -296,9 +296,9 @@ public class FlatpackFactoryTest {
//
System.out.println(file.getAbsolutePath());
W3CWidget fpWidget = fac.parse(file);
- assertEquals("moderator", fpWidget.getPrefences().get(0).getName());
- assertEquals("true", fpWidget.getPrefences().get(0).getValue());
- assertEquals(1,fpWidget.getPrefences().size());
+ assertEquals("moderator", fpWidget.getPreferences().get(0).getName());
+ assertEquals("true", fpWidget.getPreferences().get(0).getValue());
+ assertEquals(1,fpWidget.getPreferences().size());
}
/**
Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java Tue Jun 12 12:38:28 2012
@@ -31,10 +31,10 @@ import org.apache.commons.httpclient.met
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.io.FileUtils;
-import org.apache.wookie.w3c.W3CWidget;
import org.apache.wookie.w3c.W3CWidgetFactory;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.exceptions.BadWidgetZipFileException;
+import org.apache.wookie.w3c.W3CWidget;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
Modified: incubator/wookie/trunk/src/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/META-INF/persistence.xml?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/META-INF/persistence.xml (original)
+++ incubator/wookie/trunk/src/META-INF/persistence.xml Tue Jun 12 12:38:28 2012
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="wookie" transaction-type="RESOURCE_LOCAL">
Modified: incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java Tue Jun 12 12:38:28 2012
@@ -24,8 +24,8 @@ import javax.servlet.http.HttpServletReq
import org.apache.log4j.Logger;
import org.apache.wookie.Messages;
import org.apache.wookie.ajaxmodel.IWidgetAPI;
-import org.apache.wookie.beans.IDescription;
-import org.apache.wookie.beans.IName;
+import org.apache.wookie.w3c.IDescription;
+import org.apache.wookie.w3c.IName;
import org.apache.wookie.beans.IPreference;
import org.apache.wookie.beans.IWidget;
import org.apache.wookie.beans.IWidgetInstance;
@@ -114,7 +114,7 @@ public class WidgetAPIImpl implements IW
// Add in metadata
- map.put("id", String.valueOf(widget.getGuid())); //$NON-NLS-1$
+ map.put("id", String.valueOf(widget.getIdentifier())); //$NON-NLS-1$
map.put("author", author); //$NON-NLS-1$
map.put("authorEmail", email);//$NON-NLS-1$
map.put("authorHref", href);//$NON-NLS-1$
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java Tue Jun 12 12:38:28 2012
@@ -20,6 +20,7 @@ import org.apache.wookie.helpers.WidgetR
import org.apache.wookie.util.WidgetFormattingUtils;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.LocalizationUtils;
+import org.apache.wookie.w3c.*;
/**
* IWidget - a simple bean to model a widgets attributes.
@@ -28,16 +29,10 @@ import org.apache.wookie.w3c.util.Locali
* @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
* @version $Id$
*/
-public interface IWidget extends ILocalizedBean, IBean
+public interface IWidget extends W3CWidget, IBean
{
/**
- * Get the default locale
- * @return
- */
- String getDefaultLocale();
-
- /**
* Set the the default locale
* @param locale the locale to set as default
*/
@@ -52,23 +47,10 @@ public interface IWidget extends ILocali
void setPackagePath(String path);
/**
- * Get widget update location
- * @return widget update location as a string
- */
- String getUpdateLocation();
-
- /**
* Set the widget update location
* @param location the location to set
*/
void setUpdateLocation(String location);
-
- /**
- * Get widget height.
- *
- * @return widget height
- */
- Integer getHeight();
/**
* Set widget height.
@@ -76,13 +58,6 @@ public interface IWidget extends ILocali
* @param height widget height
*/
void setHeight(Integer height);
-
- /**
- * Get widget width.
- *
- * @return widget width
- */
- Integer getWidth();
/**
* Set widget width.
@@ -90,39 +65,19 @@ public interface IWidget extends ILocali
* @param width widget width
*/
void setWidth(Integer width);
-
- /**
- * Get widget GUID.
- *
- * @return widget GUID
- */
- String getGuid();
/**
* Set widget GUID.
*
* @param guid widget GUID
*/
- void setGuid(String guid);
-
- /**
- * Get the widget author
- * @return widget author
- */
- IAuthor getAuthor();
+ void setIdentifier(String guid);
/**
* Set the widget author
* @param author the author to set
*/
void setAuthor(IAuthor author);
-
- /**
- * Get widget version number.
- *
- * @return widget version
- */
- String getVersion();
/**
* Set widget version number.
@@ -132,39 +87,18 @@ public interface IWidget extends ILocali
void setVersion(String version);
/**
- * Get collection of features for this widget.
- *
- * @return features collection
- */
- Collection<IFeature> getFeatures();
-
- /**
* Set collection of features for this widget.
*
* @param features features collection
*/
void setFeatures(Collection<IFeature> features);
-
- /**
- * Get collection of widget icons for this widget.
- *
- * @return widget icons collection
- */
- Collection<IWidgetIcon> getWidgetIcons();
/**
* Set collection of widget icons for this widget.
*
* @param widgetIcons widget icons collection
*/
- void setWidgetIcons(Collection<IWidgetIcon> widgetIcons);
-
- /**
- * Get collection of licenses for this widget.
- *
- * @return licenses collection
- */
- Collection<ILicense> getLicenses();
+ void setIcons(Collection<IIcon> widgetIcons);
/**
* Set collection of licenses for this widget.
@@ -172,13 +106,6 @@ public interface IWidget extends ILocali
* @param licenses licenses collection
*/
void setLicenses(Collection<ILicense> licenses);
-
- /**
- * Get collection of names for this widget.
- *
- * @return names collection
- */
- Collection<IName> getNames();
/**
* Set collection of names for this widget.
@@ -188,53 +115,25 @@ public interface IWidget extends ILocali
void setNames(Collection<IName> names);
/**
- * Get collection of descriptions for this widget.
- *
- * @return descriptions collection
- */
- Collection<IDescription> getDescriptions();
-
- /**
* Set collection of descriptions for this widget.
*
* @param descriptions descriptions collection
*/
void setDescriptions(Collection<IDescription> descriptions);
-
- /**
- * Get collection of start files for this widget.
- *
- * @return start files collection
- */
- Collection<IStartFile> getStartFiles();
/**
* Set collection of start files for this widget.
*
* @param startFiles start files collection
*/
- void setStartFiles(Collection<IStartFile> startFiles);
-
- /**
- * Get collection of preference defaults for this widget.
- *
- * @return preference defaults collection
- */
- Collection<IPreferenceDefault> getPreferenceDefaults();
+ void setContentList(Collection<IContent> startFiles);
/**
* Set collection of preference defaults for this widget.
*
* @param preferenceDefaults preference defaults collection
*/
- void setPreferenceDefaults(Collection<IPreferenceDefault> preferenceDefaults);
-
- /**
- * Get widget title for locale.
- *
- * @return widget title
- */
- String getWidgetTitle(String locale);
+ void setPreferences(Collection<org.apache.wookie.w3c.IPreference> preferenceDefaults);
/**
* Shared implementation utilities.
@@ -305,9 +204,9 @@ public interface IWidget extends ILocali
*/
public static String getUrl(IWidget widget, String locale)
{
- IStartFile[] startFiles = widget.getStartFiles().toArray(new IStartFile[widget.getStartFiles().size()]);
- IStartFile startFile = (IStartFile)LocalizationUtils.getLocalizedElement(startFiles, new String[]{locale}, widget.getDefaultLocale());
- return ((startFile != null) ? startFile.getUrl() : null);
+ IContent[] startFiles = widget.getContentList().toArray(new IContent[widget.getContentList().size()]);
+ IContent startFile = (IContent)LocalizationUtils.getLocalizedElement(startFiles, new String[]{locale}, widget.getDefaultLocale());
+ return ((startFile != null) ? startFile.getSrc() : null);
}
@@ -320,8 +219,8 @@ public interface IWidget extends ILocali
*/
public static String getWidgetIconLocation(IWidget widget, String locale)
{
- IWidgetIcon[] icons = widget.getWidgetIcons().toArray(new IWidgetIcon[widget.getWidgetIcons().size()]);
- IWidgetIcon icon = (IWidgetIcon)LocalizationUtils.getLocalizedElement(icons, new String[]{locale}, widget.getDefaultLocale());
+ IIcon[] icons = widget.getIcons().toArray(new IIcon[widget.getIcons().size()]);
+ IIcon icon = (IIcon)LocalizationUtils.getLocalizedElement(icons, new String[]{locale}, widget.getDefaultLocale());
return ((icon != null) ? icon.getSrc() : WidgetRuntimeHelper.DEFAULT_ICON_PATH);
}
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/IWidgetInstance.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/IWidgetInstance.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/IWidgetInstance.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/IWidgetInstance.java Tue Jun 12 12:38:28 2012
@@ -15,12 +15,7 @@
package org.apache.wookie.beans;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.wookie.beans.util.IPersistenceManager;
-import org.apache.wookie.beans.util.PersistenceManagerFactory;
-import org.apache.wookie.w3c.ILocalizedElement;
+import org.apache.wookie.w3c.ILocalized;
/**
* IWidgetInstance - a simple bean to model an actual widgets instance attributes.
@@ -29,7 +24,7 @@ import org.apache.wookie.w3c.ILocalizedE
* @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
* @version $Id$
*/
-public interface IWidgetInstance extends IBean, ILocalizedElement
+public interface IWidgetInstance extends IBean, ILocalized
{
/**
* Get owning widget instance.
@@ -228,13 +223,10 @@ public interface IWidgetInstance extends
*/
public static IPreference getPreference(IWidgetInstance widgetInstance, String key)
{
- IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("widgetInstance", widgetInstance);//$NON-NLS-1$
- map.put("dkey", key);//$NON-NLS-1$
- IPreference[] preference = persistenceManager.findByValues(IPreference.class, map);
- if (preference.length == 1) return preference[0];
- return null;
+ for (IPreference preference: widgetInstance.getPreferences()){
+ if (preference.getDkey().equals(key)) return preference;
+ }
+ return null;
}
}
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java Tue Jun 12 12:38:28 2012
@@ -47,21 +47,20 @@ import org.apache.openjpa.persistence.Op
import org.apache.openjpa.persistence.OpenJPAPersistence;
import org.apache.openjpa.persistence.QueryResultCache;
import org.apache.openjpa.persistence.StoreCache;
-import org.apache.wookie.beans.IAuthor;
+import org.apache.wookie.w3c.IAuthor;
import org.apache.wookie.beans.IBean;
-import org.apache.wookie.beans.IDescription;
-import org.apache.wookie.beans.IFeature;
-import org.apache.wookie.beans.ILicense;
-import org.apache.wookie.beans.IName;
+import org.apache.wookie.w3c.IContent;
+import org.apache.wookie.w3c.IDescription;
+import org.apache.wookie.w3c.IFeature;
+import org.apache.wookie.w3c.ILicense;
+import org.apache.wookie.w3c.IName;
import org.apache.wookie.beans.IOAuthToken;
-import org.apache.wookie.beans.IParam;
+import org.apache.wookie.w3c.IParam;
import org.apache.wookie.beans.IParticipant;
import org.apache.wookie.beans.IPreference;
-import org.apache.wookie.beans.IPreferenceDefault;
import org.apache.wookie.beans.ISharedData;
-import org.apache.wookie.beans.IStartFile;
import org.apache.wookie.beans.IWidget;
-import org.apache.wookie.beans.IWidgetIcon;
+import org.apache.wookie.w3c.IIcon;
import org.apache.wookie.beans.IWidgetInstance;
import org.apache.wookie.beans.jpa.impl.AuthorImpl;
import org.apache.wookie.beans.jpa.impl.DescriptionImpl;
@@ -114,11 +113,11 @@ public class JPAPersistenceManager imple
INTERFACE_TO_CLASS_MAP.put(IParam.class, ParamImpl.class);
INTERFACE_TO_CLASS_MAP.put(IParticipant.class, ParticipantImpl.class);
INTERFACE_TO_CLASS_MAP.put(IPreference.class, PreferenceImpl.class);
- INTERFACE_TO_CLASS_MAP.put(IPreferenceDefault.class, PreferenceDefaultImpl.class);
+ INTERFACE_TO_CLASS_MAP.put(org.apache.wookie.w3c.IPreference.class, PreferenceDefaultImpl.class);
INTERFACE_TO_CLASS_MAP.put(ISharedData.class, SharedDataImpl.class);
- INTERFACE_TO_CLASS_MAP.put(IStartFile.class, StartFileImpl.class);
+ INTERFACE_TO_CLASS_MAP.put(IContent.class, StartFileImpl.class);
INTERFACE_TO_CLASS_MAP.put(IWidget.class, WidgetImpl.class);
- INTERFACE_TO_CLASS_MAP.put(IWidgetIcon.class, WidgetIconImpl.class);
+ INTERFACE_TO_CLASS_MAP.put(IIcon.class, WidgetIconImpl.class);
INTERFACE_TO_CLASS_MAP.put(IWidgetInstance.class, WidgetInstanceImpl.class);
INTERFACE_TO_CLASS_MAP.put(IOAuthToken.class, OAuthTokenImpl.class);
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/AuthorImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/AuthorImpl.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/AuthorImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/AuthorImpl.java Tue Jun 12 12:38:28 2012
@@ -17,29 +17,25 @@ package org.apache.wookie.beans.jpa.impl
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
-import org.apache.wookie.beans.IAuthor;
-import org.apache.wookie.beans.jpa.IInverseRelationship;
+import org.apache.wookie.w3c.IAuthor;
/**
* AuthorImpl - JPA IAuthor implementation.
*/
@Entity(name="Author")
@Table(name="Author")
-public class AuthorImpl extends LocalizedBeanImpl implements IAuthor, IInverseRelationship<WidgetImpl>
+public class AuthorImpl extends LocalizedBeanImpl implements IAuthor
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id", nullable=false)
- @SuppressWarnings("unused")
+ @SuppressWarnings("unused")
private int id;
@Version
@@ -58,11 +54,6 @@ public class AuthorImpl extends Localize
@Basic
@Column(name="href")
private String href;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(name="widget_id", referencedColumnName="id")
- @SuppressWarnings("unused")
- private WidgetImpl widget;
/* (non-Javadoc)
* @see org.apache.wookie.beans.IAuthor#getAuthor()
@@ -105,11 +96,4 @@ public class AuthorImpl extends Localize
public void setHref(String href) {
this.href = href;
}
-
- /* (non-Javadoc)
- * @see org.apache.wookie.beans.jpa.IInverseRelationship#updateInverseRelationship(java.lang.Object)
- */
- public void updateInverseRelationship(WidgetImpl owningObject) {
- widget = owningObject;
- }
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/DescriptionImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/DescriptionImpl.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/DescriptionImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/DescriptionImpl.java Tue Jun 12 12:38:28 2012
@@ -17,17 +17,13 @@ package org.apache.wookie.beans.jpa.impl
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
-import org.apache.wookie.beans.IDescription;
-import org.apache.wookie.beans.jpa.IInverseRelationship;
+import org.apache.wookie.w3c.IDescription;
/**
* DescriptionImpl - JPA IDescription implementation.
@@ -37,7 +33,7 @@ import org.apache.wookie.beans.jpa.IInve
*/
@Entity(name="Description")
@Table(name="Description")
-public class DescriptionImpl extends LocalizedBeanImpl implements IDescription, IInverseRelationship<WidgetImpl>
+public class DescriptionImpl extends LocalizedBeanImpl implements IDescription
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@@ -54,19 +50,6 @@ public class DescriptionImpl extends Loc
@Column(name="content")
private String content;
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(name="widget_id", referencedColumnName="id")
- @SuppressWarnings("unused")
- private WidgetImpl widget;
-
- /* (non-Javadoc)
- * @see org.apache.wookie.beans.util.IInverseRelationship#updateInverseRelationship(java.lang.Object)
- */
- public void updateInverseRelationship(WidgetImpl owningObject)
- {
- widget = owningObject;
- }
-
/* (non-Javadoc)
* @see org.apache.wookie.beans.IDescription#getContent()
*/
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/FeatureImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/FeatureImpl.java?rev=1349299&r1=1349298&r2=1349299&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/FeatureImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/FeatureImpl.java Tue Jun 12 12:38:28 2012
@@ -22,24 +22,19 @@ import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
-import org.apache.openjpa.persistence.ElementDependent;
import org.apache.openjpa.persistence.ExternalValues;
import org.apache.openjpa.persistence.Type;
-import org.apache.wookie.beans.IFeature;
-import org.apache.wookie.beans.IParam;
-import org.apache.wookie.beans.jpa.IInverseRelationship;
-import org.apache.wookie.beans.jpa.InverseRelationshipCollection;
+import org.apache.wookie.w3c.IFeature;
+import org.apache.wookie.w3c.IParam;
/**
* FeatureImpl - JPA IFeature implementation.
@@ -49,7 +44,7 @@ import org.apache.wookie.beans.jpa.Inver
*/
@Entity(name="Feature")
@Table(name="Feature")
-public class FeatureImpl implements IFeature, IInverseRelationship<WidgetImpl>
+public class FeatureImpl implements IFeature
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@@ -71,25 +66,12 @@ public class FeatureImpl implements IFea
@ExternalValues({"true=t","false=f","null="})
@Type(String.class)
private Boolean required;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(name="widget_id", referencedColumnName="id")
- @SuppressWarnings("unused")
- private WidgetImpl widget;
-
- @OneToMany(mappedBy="parentFeature", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
- @ElementDependent
+
+ @OneToMany(cascade=CascadeType.ALL)
+ @JoinColumn(name="feature_id")
private Collection<ParamImpl> parameters;
/* (non-Javadoc)
- * @see org.apache.wookie.beans.util.IInverseRelationship#updateInverseRelationship(java.lang.Object)
- */
- public void updateInverseRelationship(WidgetImpl owningObject)
- {
- widget = owningObject;
- }
-
- /* (non-Javadoc)
* @see org.apache.wookie.beans.IFeature#getFeatureName()
*/
public String getName()
@@ -108,15 +90,14 @@ public class FeatureImpl implements IFea
/* (non-Javadoc)
* @see org.apache.wookie.beans.IFeature#getParameters()
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public List<IParam> getParameters()
{
if (parameters == null)
{
parameters = new ArrayList<ParamImpl>();
}
- ArrayList<IParam> params = new ArrayList<IParam>();
- params.addAll( new InverseRelationshipCollection<FeatureImpl,ParamImpl,IParam>(this, parameters));
- return params;
+ return (ArrayList<IParam>)(List)parameters;
}
/* (non-Javadoc)