Author: julien(a)jboss.com
Date: 2007-12-21 17:17:58 -0500 (Fri, 21 Dec 2007)
New Revision: 9382
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java
Log:
move relationship classes to inner static classes as it will be easier to enforce
encapsulation of the state for the same package while allowing the 2 classes to access
each other state
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java 2007-12-21
21:57:12 UTC (rev 9381)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java 2007-12-21
22:17:58 UTC (rev 9382)
@@ -47,10 +47,10 @@
final UIManagedObject managedObject;
/** . */
- final UIObjectOneToMany children;
+ final UIObjectRelationship.OneToMany children;
/** . */
- final UIObjectManyToOne parent;
+ final UIObjectRelationship.ManyToOne parent;
/** . */
StructuralObject structuralObject;
@@ -74,8 +74,8 @@
this.structuralObject = structuralObject;
this.status = UIObject.Status.VALID;
this.managedObject = new UIManagedObject(this);
- this.children = new UIObjectOneToMany(this);
- this.parent = new UIObjectManyToOne(this);
+ this.children = new UIObjectRelationship.OneToMany(this);
+ this.parent = new UIObjectRelationship.ManyToOne(this);
}
// Public
***********************************************************************************************************
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java 2007-12-21
21:57:12 UTC (rev 9381)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java 2007-12-21
22:17:58 UTC (rev 9382)
@@ -1,64 +0,0 @@
-/******************************************************************************
- * 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.portal.presentation.impl.model.container;
-
-/**
- * A lazy reference.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-final class UIObjectManyToOne
-{
-
- /** . */
- private final UIObjectContext owner;
-
- /** . */
- private boolean loaded;
-
- /** . */
- private UIContainerObject related;
-
- UIObjectManyToOne(UIObjectContext owner)
- {
- this.owner = owner;
- }
-
- UIContainerObject get()
- {
- if (!loaded)
- {
- related = owner.container.getParent(owner.structuralObject);
- }
-
- //
- return related;
- }
-
- void clear()
- {
- related = null;
- loaded = false;
- }
-}
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java 2007-12-21
21:57:12 UTC (rev 9381)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java 2007-12-21
22:17:58 UTC (rev 9382)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * 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.portal.presentation.impl.model.container;
-
-import java.util.AbstractList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-final class UIObjectOneToMany
-{
-
- /** . */
- private final ProxyList list;
-
- /** . */
- private final UIObjectContext owner;
-
- /** . */
- private List<UIContainerObject> relateds;
-
- UIObjectOneToMany(UIObjectContext object)
- {
- this.owner = object;
- this.list = new ProxyList();
- this.relateds = null;
- }
-
- List<UIContainerObject> get()
- {
- return list;
- }
-
- void clear()
- {
- relateds = null;
- }
-
- private class ProxyList extends AbstractList<UIContainerObject>
- {
- public UIContainerObject get(int i)
- {
- if (!owner.isValid())
- {
- throw new IllegalStateException("Relationship not valid");
- }
-
- // Load the entire relationship
- if (relateds == null)
- {
- relateds = owner.container.getChildren(owner.structuralObject);
- }
-
- //
- return relateds.get(i);
- }
-
- public int size()
- {
- if (!owner.isValid())
- {
- throw new IllegalStateException("Relationship not valid");
- }
- if (relateds == null)
- {
- relateds = owner.container.getChildren(owner.structuralObject);
- }
- return relateds.size();
- }
- }
-}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java 2007-12-21
22:17:58 UTC (rev 9382)
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * 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.portal.presentation.impl.model.container;
+
+import java.util.List;
+import java.util.AbstractList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectRelationship
+{
+
+ final static class ManyToOne
+ {
+
+ /** . */
+ private final UIObjectContext owner;
+
+ /** . */
+ private boolean loaded;
+
+ /** . */
+ private UIContainerObject related;
+
+ ManyToOne(UIObjectContext owner)
+ {
+ this.owner = owner;
+ }
+
+ UIContainerObject get()
+ {
+ if (!loaded)
+ {
+ related = owner.container.getParent(owner.structuralObject);
+ }
+
+ // Try to resolve the relationship
+
+
+ //
+ return related;
+ }
+
+ void clear()
+ {
+ related = null;
+ loaded = false;
+ }
+ }
+
+ final static class OneToMany
+ {
+
+ /** . */
+ private final ProxyList list;
+
+ /** . */
+ private final UIObjectContext owner;
+
+ /** . */
+ private List<UIContainerObject> relateds;
+
+ OneToMany(UIObjectContext object)
+ {
+ this.owner = object;
+ this.list = new ProxyList();
+ this.relateds = null;
+ }
+
+ List<UIContainerObject> get()
+ {
+ return list;
+ }
+
+ void clear()
+ {
+ relateds = null;
+ }
+
+ private class ProxyList extends AbstractList<UIContainerObject>
+ {
+ public UIContainerObject get(int i)
+ {
+ if (!owner.isValid())
+ {
+ throw new IllegalStateException("Relationship not valid");
+ }
+
+ // Load the entire relationship
+ if (relateds == null)
+ {
+ relateds = owner.container.getChildren(owner.structuralObject);
+ }
+
+ //
+ return relateds.get(i);
+ }
+
+ public int size()
+ {
+ if (!owner.isValid())
+ {
+ throw new IllegalStateException("Relationship not valid");
+ }
+ if (relateds == null)
+ {
+ relateds = owner.container.getChildren(owner.structuralObject);
+ }
+ return relateds.size();
+ }
+ }
+ }
+}