You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by st...@apache.org on 2004/09/09 17:39:37 UTC
cvs commit: jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/nodetype ChildItemDef.java ItemDefImpl.java ItemDef.java
stefan 2004/09/09 08:39:37
Added: proposals/jcrri/src/org/apache/slide/jcr/core/nodetype
ChildItemDef.java ItemDefImpl.java
Removed: proposals/jcrri/src/org/apache/slide/jcr/core/nodetype
ItemDef.java
Log:
jcrri: refactoring of PropertyDef & NodeDef interfaces
Revision Changes Path
1.1 jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/nodetype/ChildItemDef.java
Index: ChildItemDef.java
===================================================================
/*
* Copyright 2002-2004 The Apache Software Foundation.
*
* 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.slide.jcr.core.nodetype;
import org.apache.slide.jcr.core.QName;
import javax.jcr.version.OnParentVersionAction;
/**
* An <code>ItemDef</code> ...
*
* @author Stefan Guggisberg
* @version $Revision: 1.1 $, $Date: 2004/09/09 15:39:37 $
*/
abstract class ChildItemDef implements Cloneable {
protected QName declaringNodeType = null;
private QName name = null;
private boolean autoCreate = false;
private int onParentVersion = OnParentVersionAction.COPY;
private boolean writeProtected = false;
private boolean mandatory = false;
private boolean primaryItem = false;
protected Object clone() throws CloneNotSupportedException {
// delegate to superclass which does a shallow copy;
// but since all fields are either primitives or immutables
// this is sufficient
return super.clone();
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ChildItemDef) {
ChildItemDef other = (ChildItemDef) obj;
return (declaringNodeType == null ? other.declaringNodeType == null : declaringNodeType.equals(other.declaringNodeType)) &&
(name == null ? other.name == null : name.equals(other.name)) &&
autoCreate == other.autoCreate &&
onParentVersion == other.onParentVersion &&
writeProtected == other.writeProtected &&
mandatory == other.mandatory &&
primaryItem == other.primaryItem;
}
return false;
}
public void setDeclaringNodeType(QName declaringNodeType) {
this.declaringNodeType = declaringNodeType;
}
public void setName(QName name) {
this.name = name;
}
public void setAutoCreate(boolean autoCreate) {
this.autoCreate = autoCreate;
}
public void setOnParentVersion(int onParentVersion) {
this.onParentVersion = onParentVersion;
}
public void setProtected(boolean writeProtected) {
this.writeProtected = writeProtected;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public void setPrimaryItem(boolean primaryItem) {
this.primaryItem = primaryItem;
}
public QName getDeclaringNodeType() {
return declaringNodeType;
}
public QName getName() {
return name;
}
public boolean isAutoCreate() {
return autoCreate;
}
public int getOnParentVersion() {
return onParentVersion;
}
public boolean isProtected() {
return writeProtected;
}
public boolean isMandatory() {
return mandatory;
}
public boolean isPrimaryItem() {
return primaryItem;
}
public abstract boolean definesNode();
}
1.1 jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/nodetype/ItemDefImpl.java
Index: ItemDefImpl.java
===================================================================
/*
* Copyright 2002-2004 The Apache Software Foundation.
*
* 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.slide.jcr.core.nodetype;
import org.apache.log4j.Logger;
import org.apache.slide.jcr.core.NamespaceResolver;
import org.apache.slide.jcr.core.NoPrefixDeclaredException;
import org.apache.slide.jcr.core.QName;
import javax.jcr.nodetype.ItemDef;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeType;
/**
* An <code>ItemDefImpl</code> ...
*
* @author Stefan Guggisberg
* @version $Revision: 1.1 $, $Date: 2004/09/09 15:39:37 $
*/
abstract class ItemDefImpl implements ItemDef {
private static Logger log = Logger.getLogger(ItemDefImpl.class);
protected final NodeTypeManagerImpl ntMgr;
// namespace resolver used to translate qualified names to JCR names
protected final NamespaceResolver nsResolver;
private final ChildItemDef itemDef;
/**
* Package private constructor
*
* @param itemDef item definition
* @param ntMgr node type manager
* @param nsResolver namespace resolver
*/
ItemDefImpl(ChildItemDef itemDef, NodeTypeManagerImpl ntMgr, NamespaceResolver nsResolver) {
this.itemDef = itemDef;
this.ntMgr = ntMgr;
this.nsResolver = nsResolver;
}
public QName getQName() {
return itemDef.getName();
}
//--------------------------------------------------------------< ItemDef >
/**
* @see ItemDef#getDeclaringNodeType
*/
public NodeType getDeclaringNodeType() {
try {
return ntMgr.getNodeType(itemDef.getDeclaringNodeType());
} catch (NoSuchNodeTypeException e) {
// should never get here
log.error("declaring node type does not exist", e);
return null;
}
}
/**
* @see ItemDef#getName
*/
public String getName() {
QName name = itemDef.getName();
if (name == null) {
return null;
}
try {
return name.toJCRName(nsResolver);
} catch (NoPrefixDeclaredException npde) {
// should never get here
log.error("encountered unregistered namespace in property name", npde);
// not correct, but an acceptable fallback
return itemDef.getName().toString();
}
}
/**
* @see ItemDef#getOnParentVersion()
*/
public int getOnParentVersion() {
return itemDef.getOnParentVersion();
}
/**
* @see ItemDef#isAutoCreate
*/
public boolean isAutoCreate() {
return itemDef.isAutoCreate();
}
/**
* @see ItemDef#isMandatory
*/
public boolean isMandatory() {
return itemDef.isMandatory();
}
/**
* @see ItemDef#isPrimaryItem
*/
public boolean isPrimaryItem() {
return itemDef.isPrimaryItem();
}
/**
* @see ItemDef#isProtected
*/
public boolean isProtected() {
return itemDef.isProtected();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org