[jbosside-dev] Re: [jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb ...

Max Rydahl Andersen max.andersen at redhat.com
Tue Apr 17 03:24:34 EDT 2007


>   Log:
>   Complete rewrite of the the two plugins leading to a cleaner, leaner

Cool - any sign of us using a better name than "package" soon ? :)

/max


> project.
>  Revision  Changes    Path
>   1.4       +1 -29      
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbPackage.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbPackage.java
>   ===================================================================
>   RCS file: XbPackage.java
>   diff -N XbPackage.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbPackage.java	16 Apr 2007 17:34:43 -0000	1.4
>   @@ -0,0 +1,120 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.List;
>   +
>   +public class XbPackage extends XbPackageNodeWithProperties {
>   +
>   +	private String name, packageType, toDir;
>   +	private boolean exploded, inWorkspace;
>   +
>   +	public XbPackage () {
>   +		super();
>   +		exploded = false;
>   +		inWorkspace = true;
>   +	}
>   +	
>   +	public XbPackage (XbPackage pkg)
>   +	{
>   +		super(pkg);
>   +		copyFrom (pkg);
>   +	}
>   +	
>   +	public void copyFrom (XbPackage pkg)
>   +	{
>   +		this.name = pkg.name == null ? null: new String(pkg.name);
>   +		this.packageType = pkg.packageType == null ? null : new  
> String(pkg.packageType);
>   +		this.toDir = pkg.toDir == null ? null : new String(pkg.toDir);
>   +		this.exploded = pkg.exploded;
>   +		this.inWorkspace = pkg.inWorkspace;
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbPackage(this);
>   +	}
>   +	
>   +	public List getPackages ()
>   +	{
>   +		return getChildren(XbPackage.class);
>   +	}
>   +	
>   +	public List getFolders ()
>   +	{
>   +		return getChildren(XbFolder.class);
>   +	}
>   +	
>   +	public List getFileSets()
>   +	{
>   +		return getChildren(XbFileSet.class);
>   +	}
>   +	
>   +	public boolean isExploded() {
>   +		return exploded;
>   +	}
>   +
>   +	public void setExploded(boolean exploded) {
>   +		this.exploded = exploded;
>   +	}
>   +
>   +	public String getName() {
>   +		return name;
>   +	}
>   +
>   +	public void setName(String name) {
>   +		this.name = name;
>   +	}
>   +
>   +	public String getToDir() {
>   +		return toDir;
>   +	}
>   +
>   +	public void setToDir(String toDir) {
>   +		this.toDir = toDir;
>   +	}
>   +
>   +	public String getPackageType() {
>   +		return packageType;
>   +	}
>   +
>   +	public void setPackageType(String packageType) {
>   +		this.packageType = packageType;
>   +	}
>   +
>   +	/**
>   +	 * Get the inWorkspace.
>   +	 *
>   +	 * @return the inWorkspace.
>   +	 */
>   +	public boolean isInWorkspace() {
>   +		return inWorkspace;
>   +	}
>   +
>   +	/**
>   +	 * Set the inWorkspace.
>   +	 *
>   +	 * @param inWorkspace The inWorkspace to set.
>   +	 */
>   +	public void setInWorkspace(boolean inWorkspace) {
>   +		this.inWorkspace = inWorkspace;
>   +	}
>   +}
>  1.3       +0 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbProperty.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbProperty.java
>   ===================================================================
>   RCS file: XbProperty.java
>   diff -N XbProperty.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbProperty.java	16 Apr 2007 17:34:43 -0000	1.3
>   @@ -0,0 +1,58 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +
>   +public class XbProperty extends XbPackageNode {
>   +
>   +	private String name, value;
>   +	
>   +	public XbProperty () {
>   +		super();
>   +	}
>   +	
>   +	public XbProperty(XbProperty property) {
>   +		this.name = property.name == null ? null : new  
> String(property.name);
>   +		this.value = property.value ==  null ? null : new  
> String(property.value);
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbProperty(this);
>   +	}
>   +	
>   +	public String getName() {
>   +		return name;
>   +	}
>   +
>   +	public void setName(String name) {
>   +		this.name = name;
>   +	}
>   +
>   +	public String getValue() {
>   +		return value;
>   +	}
>   +
>   +	public void setValue(String value) {
>   +		this.value = value;
>   +	}
>   +	
>   +}
>  1.5       +0 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbPackageNodeWithProperties.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbPackageNodeWithProperties.java
>   ===================================================================
>   RCS file: XbPackageNodeWithProperties.java
>   diff -N XbPackageNodeWithProperties.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbPackageNodeWithProperties.java	16 Apr 2007 17:34:43 -0000	1.5
>   @@ -0,0 +1,71 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.Iterator;
>   +import java.util.Properties;
>   +
>   +public abstract class XbPackageNodeWithProperties extends  
> XbPackageNode {
>   +
>   +	protected XbProperties properties;
>   +	
>   +	public XbPackageNodeWithProperties ()
>   +	{
>   +		super();
>   +		
>   +		properties = new XbProperties();
>   +	}
>   +	
>   +	public XbPackageNodeWithProperties (XbPackageNodeWithProperties node)
>   +	{
>   +		super(node);
>   +	}
>   +	
>   +	public void copyFrom (XbPackageNodeWithProperties node)
>   +	{
>   +		properties.getProperties().clear();
>   +		
>   +		Properties props = node.getProperties().getProperties();
>   +		for (Iterator iter = props.keySet().iterator(); iter.hasNext(); )
>   +		{
>   +			String key = (String) iter.next();
>   +			
>   +			properties.getProperties().setProperty(key, (String)  
> props.get(key));
>   +		}
>   +	}
>   +	
>   +	public XbProperties getProperties ()
>   +	{
>   +		return properties;
>   +	}
>   +	
>   +	public void setProperties (Object object)
>   +	{
>   +		setProperties((XbProperties)object);
>   +	}
>   +	
>   +	protected void setProperties (XbProperties properties)
>   +	{
>   +		this.properties = properties;
>   +	}
>   +
>   +}
>  1.5       +10 -1      
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbPackageNode.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbPackageNode.java
>   ===================================================================
>   RCS file: XbPackageNode.java
>   diff -N XbPackageNode.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbPackageNode.java	16 Apr 2007 17:34:43 -0000	1.5
>   @@ -0,0 +1,107 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.ArrayList;
>   +import java.util.Hashtable;
>   +import java.util.Iterator;
>   +import java.util.List;
>   +
>   +public abstract class XbPackageNode implements Cloneable {
>   +	
>   +	protected XbPackageNode parent;
>   +	
>   +	/**
>   +	 * The children are a class -> arraylist[child] map hashmap
>   +	 */
>   +	protected Hashtable children;
>   +	
>   +	public XbPackageNode ()
>   +	{
>   +		children = new Hashtable();
>   +	}
>   +	
>   +	public XbPackageNode(XbPackageNode node)
>   +	{
>   +		children = new Hashtable();
>   +		Object key;
>   +		for( Iterator i = node.children.keySet().iterator(); i.hasNext(); )  
> {
>   +			key = i.next();
>   +			children.put(key, ((ArrayList)node.children.get(key)).clone());
>   +		}
>   +	}
>   +	
>   +	public void addChild (Object object)
>   +	{
>   +		addChild((XbPackageNode)object);
>   +	}
>   +	
>   +	public void addChild (XbPackageNode child)
>   +	{
>   +		if (!children.containsKey(child.getClass()))
>   +		{
>   +			children.put(child.getClass(), new ArrayList());
>   +		}
>   +		getChildren(child.getClass()).add(child);
>   +		child.setParent(this);
>   +	}
>   +	
>   +	public void removeChild (XbPackageNode child)
>   +	{
>   +		if (children.containsKey(child.getClass()))
>   +		{
>   +			getChildren(child.getClass()).remove(child);
>   +		}
>   +	}
>   +	
>   +	public List getChildren(Class type)
>   +	{
>   +		return (List)children.get(type);
>   +	}
>   +	
>   +	public boolean hasChildren ()
>   +	{
>   +		return children != null && children.size() > 0;
>   +	}
>   +	
>   +	public List getAllChildren()
>   +	{
>   +		ArrayList allChildren = new ArrayList();
>   +		
>   +		for (Iterator iter = children.keySet().iterator(); iter.hasNext();)
>   +		{
>   +			Class childType = (Class) iter.next();
>   +			allChildren.addAll(getChildren(childType));
>   +		}
>   +		return allChildren;
>   +	}
>   +	
>   +	public XbPackageNode getParent()
>   +	{
>   +		return parent;
>   +	}
>   +	
>   +	public void setParent (XbPackageNode parent)
>   +	{
>   +		this.parent = parent;
>   +	}
>   +}
>  1.4       +2 -29      
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbFileSet.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbFileSet.java
>   ===================================================================
>   RCS file: XbFileSet.java
>   diff -N XbFileSet.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbFileSet.java	16 Apr 2007 17:34:43 -0000	1.4
>   @@ -0,0 +1,84 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +public class XbFileSet extends XbPackageNodeWithProperties {
>   +
>   +	private String dir, includes, excludes;
>   +	private boolean inWorkspace;
>   +	
>   +	public XbFileSet ()
>   +	{
>   +		super();
>   +		inWorkspace = true;
>   +	}
>   +	
>   +	public XbFileSet (XbFileSet fileset)
>   +	{
>   +		super(fileset);
>   +		copyFrom(fileset);
>   +	}
>   +	
>   +	public void copyFrom (XbFileSet fileset)
>   +	{
>   +		this.dir = fileset.dir == null ? null : new String(fileset.dir);
>   +		this.includes = fileset.includes == null ? null : new  
> String(fileset.includes);
>   +		this.excludes = fileset.excludes == null ? null : new  
> String(fileset.excludes);
>   +		this.inWorkspace = fileset.inWorkspace;
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbFileSet(this);
>   +	}
>   +	
>   +	public String getDir() {
>   +		return dir;
>   +	}
>   +
>   +	public void setDir(String dir) {
>   +		this.dir = dir;
>   +	}
>   +
>   +	public String getExcludes() {
>   +		return excludes;
>   +	}
>   +
>   +	public void setExcludes(String excludes) {
>   +		this.excludes = excludes;
>   +	}
>   +
>   +	public String getIncludes() {
>   +		return includes;
>   +	}
>   +
>   +	public void setIncludes(String includes) {
>   +		this.includes = includes;
>   +	}
>   +	
>   +	public boolean isInWorkspace() {
>   +		return inWorkspace;
>   +	}
>   +
>   +	public void setInWorkspace(boolean inWorkspace) {
>   +		this.inWorkspace = inWorkspace;
>   +	}
>   +}
>  1.4       +0 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbFolder.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbFolder.java
>   ===================================================================
>   RCS file: XbFolder.java
>   diff -N XbFolder.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbFolder.java	16 Apr 2007 17:34:43 -0000	1.4
>   @@ -0,0 +1,73 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.List;
>   +
>   +public class XbFolder extends XbPackageNodeWithProperties {
>   +
>   +	private String name;
>   +	
>   +	public XbFolder ()
>   +	{
>   +		super();
>   +	}
>   +	
>   +	public XbFolder (XbFolder folder)
>   +	{
>   +		super(folder);
>   +		copyFrom(folder);
>   +	}
>   +	
>   +	public void copyFrom (XbFolder folder)
>   +	{
>   +		this.name = folder.name == null ? null : new String(folder.name);
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbFolder(this);
>   +	}
>   +	
>   +	public List getPackages ()
>   +	{
>   +		return getChildren(XbPackage.class);
>   +	}
>   +	
>   +	public List getFolders ()
>   +	{
>   +		return getChildren(XbFolder.class);
>   +	}
>   +	
>   +	public List getFileSets()
>   +	{
>   +		return getChildren(XbFileSet.class);
>   +	}
>   +	
>   +	public String getName() {
>   +		return name;
>   +	}
>   +
>   +	public void setName(String name) {
>   +		this.name = name;
>   +	}
>   +
>   +}
>  1.3       +1 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbProperties.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbProperties.java
>   ===================================================================
>   RCS file: XbProperties.java
>   diff -N XbProperties.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbProperties.java	16 Apr 2007 17:34:43 -0000	1.3
>   @@ -0,0 +1,110 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.Collection;
>   +import java.util.Hashtable;
>   +import java.util.Iterator;
>   +import java.util.Properties;
>   +
>   +
>   +public class XbProperties extends XbPackageNode {
>   +
>   +	private PropertiesExt properties;
>   +	
>   +	public XbProperties ()
>   +	{
>   +		super();
>   +		this.properties = new PropertiesExt();
>   +	}
>   +	
>   +	public XbProperties (XbProperties props)
>   +	{
>   +		super(props);
>   +		this.properties = new PropertiesExt();
>   +		for (Iterator iter = getChildren(XbProperty.class).iterator();  
> iter.hasNext(); )
>   +		{
>   +			XbProperty element = (XbProperty) iter.next();
>   +			addProperty(element);
>   +		}
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbProperties(this);
>   +	}
>   +	
>   +	public class PropertiesExt extends Properties {
>   +		private static final long serialVersionUID = 1L;
>   +		private Hashtable propertyElements;
>   +		
>   +		public PropertiesExt ()
>   +		{
>   +			propertyElements = new Hashtable();
>   +		}
>   +		
>   +		public synchronized Object put(Object key, Object value) {
>   +			if (!propertyElements.containsKey(key))
>   +			{
>   +				XbProperty element = new XbProperty();
>   +				element.setName((String)key);
>   +				element.setValue((String)value);
>   +				propertyElements.put(key, element);
>   +
>   +			}
>   +			else {
>   +				XbProperty element = (XbProperty)propertyElements.get(key);
>   +				element.setValue((String)value);
>   +			}
>   +			
>   +			return super.put(key, value);
>   +		}
>   +		
>   +		public synchronized Object remove(Object key) {
>   +			propertyElements.remove(key);
>   +			
>   +			return super.remove(key);
>   +		}
>   +		
>   +		public Collection getPropertyElements ()
>   +		{
>   +			return propertyElements.values();
>   +		}
>   +	}
>   +		
>   +	public PropertiesExt getProperties ()
>   +	{
>   +		return properties;
>   +	}
>   +	
>   +	public void addProperty (Object property)
>   +	{
>   +		addProperty((XbProperty)property);
>   +	}
>   +	
>   +	public void addProperty (XbProperty property)
>   +	{
>   +		properties.setProperty(property.getName(), property.getValue());
>   +		addChild(property);
>   +	}
>   +	
>   +	
>   +}
>  1.3       +4 -13      
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbPackagesObjectProvider.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbPackagesObjectProvider.java
>   ===================================================================
>   RCS file: XbPackagesObjectProvider.java
>   diff -N XbPackagesObjectProvider.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbPackagesObjectProvider.java	16 Apr 2007 17:34:43 -0000	1.3
>   @@ -0,0 +1,96 @@
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import org.jboss.xb.binding.GenericObjectModelProvider;
>   +import org.jboss.xb.binding.MarshallingContext;
>   +
>   +public class XbPackagesObjectProvider implements  
> GenericObjectModelProvider {
>   +
>   +	public Object getRoot(Object o, MarshallingContext context, String  
> namespaceURI, String localName) {
>   +		return o;
>   +	}
>   +	
>   +	protected Object getNodeChildren(XbPackageNode node, String name)
>   +	{
>   +		if ("package".equals(name))
>   +		{
>   +			return node.getChildren(XbPackage.class);
>   +		}
>   +		else if ("folder".equals(name))
>   +		{
>   +			return node.getChildren(XbFolder.class);
>   +		}
>   +		else if ("fileset".equals(name))
>   +		{
>   +			return node.getChildren(XbFileSet.class);
>   +		}
>   +		else if ("properties".equals(name) && node instanceof  
> XbPackageNodeWithProperties)
>   +		{
>   +			return ((XbPackageNodeWithProperties)node).getProperties();
>   +		}
>   +		else if ("property".equals(name) && node instanceof XbProperties)
>   +		{
>   +			return ((XbProperties)node).getProperties().getPropertyElements();
>   +		}
>   +		
>   +		return null;
>   +	}
>   +	
>   +	public Object getChildren(Object object, MarshallingContext context,  
> String namespaceURI, String localName)
>   +	{
>   +		if (object instanceof XbPackageNode) {
>   +			Object ret = getNodeChildren(((XbPackageNode)object), localName);
>   +			return ret;
>   +		}
>   +		return null;
>   +	}
>   +	
>   +	
>   +	public Object getAttributeValue(Object object, MarshallingContext  
> context, String namespaceURI, String localName)
>   +	{
>   +		if (object instanceof XbPackage)
>   +		{
>   +			XbPackage pkg = (XbPackage)object;
>   +			if ("type".equals(localName))
>   +				return pkg.getPackageType();
>   +			else if ("name".equals(localName))
>   +				return pkg.getName();
>   +			else if ("exploded".equals(localName))
>   +				return Boolean.valueOf(pkg.isExploded());
>   +			else if ("todir".equals(localName))
>   +				return pkg.getToDir();
>   +			else if ("inWorkspace".equals(localName))
>   +				return ""+pkg.isInWorkspace();
>   +		}
>   +		else if (object instanceof XbFolder)
>   +		{
>   +			XbFolder folder = (XbFolder) object;
>   +			if ("name".equals(localName))
>   +				return folder.getName();
>   +		}
>   +		else if (object instanceof XbFileSet)
>   +		{
>   +			XbFileSet fileset = (XbFileSet)object;
>   +			if ("dir".equals(localName))
>   +				return fileset.getDir();
>   +			else if ("includes".equals(localName))
>   +				return fileset.getIncludes();
>   +			else if ("excludes".equals(localName))
>   +				return fileset.getExcludes();
>   +			else if ("inWorkspace".equals(localName))
>   +				return "" + fileset.isInWorkspace();
>   +		}
>   +		else if (object instanceof XbProperty)
>   +		{
>   +			XbProperty prop = (XbProperty) object;
>   +			if ("name".equals(localName))
>   +				return prop.getName();
>   +			else if ("value".equals(localName))
>   +				return prop.getValue();
>   +		}
>   +		return null;
>   +	}
>   +	
>   +	public Object getElementValue(Object object, MarshallingContext  
> context, String namespaceURI, String localName) {
>   +		return null;
>   +	}
>   +}
>  1.3       +0 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XbPackages.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XbPackages.java
>   ===================================================================
>   RCS file: XbPackages.java
>   diff -N XbPackages.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XbPackages.java	16 Apr 2007 17:34:43 -0000	1.3
>   @@ -0,0 +1,45 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.util.List;
>   +
>   +public class XbPackages extends XbPackageNodeWithProperties {
>   +	
>   +	public XbPackages () {
>   +		super();
>   +	}
>   +	
>   +	public XbPackages (XbPackages packages)
>   +	{
>   +		super(packages);
>   +	}
>   +	
>   +	protected Object clone() throws CloneNotSupportedException {
>   +		return new XbPackages(this);
>   +	}
>   +	
>   +	public List getPackages ()
>   +	{
>   +		return getChildren(XbPackage.class);
>   +	}
>   +}
>  1.5       +0 -0       
> jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/internal/xb/XMLBinding.java
>  (In the diff below, changes in quantity of whitespace are not shown.)
>  Index: XMLBinding.java
>   ===================================================================
>   RCS file: XMLBinding.java
>   diff -N XMLBinding.java
>   --- /dev/null	1 Jan 1970 00:00:00 -0000
>   +++ XMLBinding.java	16 Apr 2007 17:34:43 -0000	1.5
>   @@ -0,0 +1,132 @@
>   +/*
>   + * JBoss, a division of Red Hat
>   + * Copyright 2006, Red Hat Middleware, LLC, and individual  
> contributors as indicated
>   + * by the @authors tag. See the copyright.txt in the distribution for  
> a
>   + * full listing of individual contributors.
>   + *
>   + * This is free software; you can redistribute it and/or modify it
>   + * under the terms of the GNU Lesser General Public License as
>   + * published by the Free Software Foundation; either version 2.1 of
>   + * the License, or (at your option) any later version.
>   + *
>   + * This software is distributed in the hope that it will be useful,
>   + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>   + * Lesser General Public License for more details.
>   + *
>   + * You should have received a copy of the GNU Lesser General Public
>   + * License along with this software; if not, write to the Free
>   + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>   + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>   + */
>   +package org.jboss.ide.eclipse.packages.core.model.internal.xb;
>   +
>   +import java.io.IOException;
>   +import java.io.InputStream;
>   +import java.io.InputStreamReader;
>   +import java.io.Writer;
>   +import java.net.URL;
>   +
>   +import javax.xml.parsers.ParserConfigurationException;
>   +
>   +import org.eclipse.core.runtime.IProgressMonitor;
>   +import org.jboss.ide.eclipse.packages.core.PackagesCorePlugin;
>   +import org.jboss.ide.eclipse.packages.core.Trace;
>   +import org.jboss.xb.binding.JBossXBException;
>   +import org.jboss.xb.binding.Unmarshaller;
>   +import org.jboss.xb.binding.UnmarshallerFactory;
>   +import org.jboss.xb.binding.XercesXsMarshaller;
>   +import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
>   +import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
>   +import org.xml.sax.SAXException;
>   +
>   +public class XMLBinding {
>   +	
>   +	public static final int NUM_UNMARSHAL_MONITOR_STEPS = 3;
>   +	public static final int NUM_MARSHALL_MONITOR_STEPS = 2;
>   +	
>   +	private static URL schema =  
> PackagesCorePlugin.getDefault().getBundle().getEntry("xml/packages.xsd");
>   +	private static URL log4jxml =  
> PackagesCorePlugin.getDefault().getBundle().getEntry("log4j.xml");
>   +	private static SchemaBinding binding;
>   +	
>   +	static {
>   +		System.setProperty("log4j.configuration", log4jxml.toString());
>   +	}
>   +	
>   +	public static void init ()
>   +	{
>   +		try {
>   +			InputStream stream = schema.openStream();
>   +			binding = XsdBinder.bind(stream, "UTF-8", null);
>   +
>   +			stream.close();
>   +		} catch (IOException e) {
>   +			Trace.trace(XMLBinding.class, e);
>   +		}
>   +	}
>   +	
>   +	private static void binderSandbox (Runnable runnable)
>   +	{
>   +		ClassLoader original =  
> Thread.currentThread().getContextClassLoader();
>   +		ClassLoader myCL = XMLBinding.class.getClassLoader();
>   +		Thread.currentThread().setContextClassLoader(myCL);
>   +		runnable.run();
>   +		Thread.currentThread().setContextClassLoader(original);
>   +	}
>   +	
>   +	private static XbPackages element = null;
>   +	
>   +	public static XbPackages unmarshal (final InputStream in, final  
> IProgressMonitor monitor)
>   +	{
>   +		element = null;
>   +		
>   +		binderSandbox(new Runnable() {
>   +			public void run ()  {
>   +				try {	
>   +					Unmarshaller unmarshaller =  
> UnmarshallerFactory.newInstance().newUnmarshaller();
>   +					monitor.worked(1);
>   +					
>   +					Object xmlObject = unmarshaller.unmarshal(in, binding);
>   +					monitor.worked(1);
>   +					
>   +					element = (XbPackages) xmlObject;
>   +					monitor.worked(1);
>   +					
>   +				} catch (JBossXBException e) {
>   +					Trace.trace(XMLBinding.class, e);
>   +				}
>   +			}
>   +		});
>   +		
>   +		return element;
>   +	}
>   +	
>   +	public static void marshal (final XbPackages element, final Writer  
> writer, final IProgressMonitor monitor)
>   +	{
>   +		binderSandbox(new Runnable() {
>   +			public void run ()  {
>   +				try {
>   +					InputStream stream = schema.openStream();
>   +					monitor.worked(1);
>   +					
>   +					XercesXsMarshaller marshaller = new XercesXsMarshaller();
>   +					marshaller.marshal(new InputStreamReader(stream), new  
> XbPackagesObjectProvider(), element, writer);
>   +					monitor.worked(1);
>   +					stream.close();
>   +				} catch (IOException e) {
>   +					// TODO Auto-generated catch block
>   +					e.printStackTrace();
>   +				} catch (SAXException e) {
>   +					// TODO Auto-generated catch block
>   +					e.printStackTrace();
>   +				} catch (ParserConfigurationException e) {
>   +					// TODO Auto-generated catch block
>   +					e.printStackTrace();
>   +				} catch (Exception e )
>   +				{
>   +					e.printStackTrace();
>   +				}
>   +			}
>   +		});
>   +	}
>   +}
> _______________________________________________
> jboss-cvs-commits mailing list
> jboss-cvs-commits at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-cvs-commits



-- 
--
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
max at hibernate.org
http://hibernate.org

JBoss a division of Red Hat
max.andersen at jboss.com




More information about the jbosstools-dev mailing list