Author: julien(a)jboss.com
Date: 2007-12-21 13:34:54 -0500 (Fri, 21 Dec 2007)
New Revision: 9378
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/UIObjectList.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRef.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AbstractUIObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java
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
Log:
rename association -> relationship
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AbstractUIObject.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AbstractUIObject.java 2007-12-21
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AbstractUIObject.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -54,10 +54,10 @@
protected final UIObjectContext context;
/** . */
- final UIObjectOneToMany childrenAssociation;
+ final UIObjectOneToMany childrenRelationship;
/** . */
- final UIObjectManyToOne parentAssociation;
+ final UIObjectManyToOne parentRelationship;
public AbstractUIObject(UIObjectContext context)
{
@@ -68,8 +68,8 @@
//
this.context = context;
- this.childrenAssociation = new UIObjectOneToMany(context);
- this.parentAssociation = new UIObjectManyToOne(context);
+ this.childrenRelationship = new UIObjectOneToMany(context);
+ this.parentRelationship = new UIObjectManyToOne(context);
}
// UIObject interface
implementation-----------------------------------------------------------------------------------------------------------------------------
@@ -297,7 +297,7 @@
}
//
- return parentAssociation.get();
+ return parentRelationship.get();
}
public final List<AbstractUIObject> getChildren()
@@ -308,7 +308,7 @@
}
//
- return childrenAssociation.get();
+ return childrenRelationship.get();
}
public final <T extends UIObject> T createChild(String name, Class<T>
type) throws IllegalArgumentException
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java 2007-12-21
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -29,7 +29,6 @@
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.model.state.structural.StructuralObject;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.model.state.StateException;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
@@ -356,8 +355,8 @@
else
{
object.context.structuralObject = structuralObject;
- object.parentAssociation.clear();
- object.childrenAssociation.clear();
+ object.parentRelationship.clear();
+ object.childrenRelationship.clear();
}
//
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectList.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectList.java 2007-12-21
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectList.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -1,79 +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 org.jboss.portal.presentation.model.UIObject;
-
-import java.util.AbstractList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-final class UIObjectList extends AbstractList<AbstractUIObject>
-{
-
- /** . */
- private List<AbstractUIObject> content;
-
- /** . */
- private final AbstractUIObject object;
-
- UIObjectList(AbstractUIObject object)
- {
- this.object = object;
- this.content = null;
- }
-
- public AbstractUIObject get(int i)
- {
- if (!object.context.isValid())
- {
- throw new IllegalStateException("Relationship not valid");
- }
- if (content == null)
- {
- content =
object.context.container.getChildren(object.context.structuralObject);
- }
- return content.get(i);
- }
-
- public int size()
- {
- if (!object.context.isValid())
- {
- throw new IllegalStateException("Relationship not valid");
- }
- if (content == null)
- {
- content =
object.context.container.getChildren(object.context.structuralObject);
- }
- return content.size();
- }
-
- void reset()
- {
- content = null;
- }
-}
Modified:
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
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -28,7 +28,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-final class UIObjectManyToOne extends UIObjectAssociation<AbstractUIObject>
+final class UIObjectManyToOne extends UIObjectRelationship<AbstractUIObject>
{
/** . */
Modified:
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
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-final class UIObjectOneToMany extends
UIObjectAssociation<List<AbstractUIObject>>
+final class UIObjectOneToMany extends
UIObjectRelationship<List<AbstractUIObject>>
{
/** . */
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRef.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRef.java 2007-12-21
18:20:47 UTC (rev 9377)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRef.java 2007-12-21
18:34:54 UTC (rev 9378)
@@ -1,51 +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 UIObjectRef
-{
-
- /** . */
- AbstractUIObject object;
-
- /** . */
- boolean loaded;
-
- UIObjectRef()
- {
- object = null;
- loaded = false;
- }
-
- void reset()
- {
- loaded = false;
- object = null;
- }
-}
Copied:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
(from rev 9377,
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectAssociation.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
18:34:54 UTC (rev 9378)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+abstract class UIObjectRelationship<T>
+{
+
+ /** . */
+ private static final int NOT_LOADED = 0;
+
+ /** . */
+ private static final int LOADED = 1;
+
+ /** . */
+ private int status;
+
+ /** . */
+ private T t;
+
+ public void clear()
+ {
+ if (status == LOADED)
+ {
+ T tmp = t;
+
+ //
+ t = null;
+ status = NOT_LOADED;
+
+ //
+ doEvict(tmp);
+ }
+ }
+
+ public T get()
+ {
+ if (status == NOT_LOADED)
+ {
+ t = doLoad();
+ status = LOADED;
+ }
+
+ //
+ return t;
+ }
+
+ protected final int getStatus()
+ {
+ return status;
+ }
+
+ protected abstract T doLoad();
+
+ protected abstract void doEvict(T t);
+}