diff --git a/spring-ldap-tiger/src/main/java/org/springframework/ldap/core/simple/AbstractParametrizedContextMapper.java b/spring-ldap-tiger/src/main/java/org/springframework/ldap/core/simple/AbstractParametrizedContextMapper.java new file mode 100644 index 00000000..c8b6f5aa --- /dev/null +++ b/spring-ldap-tiger/src/main/java/org/springframework/ldap/core/simple/AbstractParametrizedContextMapper.java @@ -0,0 +1,53 @@ +/* + * Copyright 2005-2007 the original author or authors. + * + * 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.springframework.ldap.core.simple; + +import org.springframework.ldap.core.DirContextOperations; + +/** + * Abstract superclass that may be used instead of implementing + * {@link ParametrizedContextMapper} directly. Subclassing from this superclass, + * the supplied context will be automatically cast to + * DirContextOperations. Note that if you use your own + * DirObjectFactory, this implementation will fail with a + * ClassCastException. + * + * @author Mattias Arthursson + * + */ +public abstract class AbstractParametrizedContextMapper implements ParametrizedContextMapper { + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.core.ContextMapper#mapFromContext(java.lang.Object) + */ + public final T mapFromContext(Object ctx) { + return doMapFromContext((DirContextOperations) ctx); + } + + /** + * Map a single DirContextOperation to an object. The + * supplied instance is the object supplied to + * {@link #mapFromContext(Object)} cast to a + * DirContextOperations. + * + * @param ctx the context to map to an object. + * @return an object built from the data in the context. + */ + protected abstract T doMapFromContext(DirContextOperations operations); + +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java b/spring-ldap/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java new file mode 100644 index 00000000..342c0b22 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java @@ -0,0 +1,55 @@ +/* + * Copyright 2005-2007 the original author or authors. + * + * 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.springframework.ldap.core.support; + +import org.springframework.ldap.core.ContextMapper; +import org.springframework.ldap.core.DirContextOperations; + +/** + * Abstract superclass that may be used instead of implementing + * {@link ContextMapper} directly. Subclassing from this superclass, the + * supplied context will be automatically cast to + * DirContextOperations. Note that if you use your own + * DirObjectFactory, this implementation will fail with a + * ClassCastException. + * + * @author Mattias Arthursson + * + */ +public abstract class AbstractContextMapper implements ContextMapper { + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.core.ContextMapper#mapFromContext(java.lang.Object) + */ + public final Object mapFromContext(Object ctx) { + return doMapFromContext((DirContextOperations) ctx); + } + + /** + * Map a single DirContextOperation to an object. The + * supplied instance is the object supplied to + * {@link #mapFromContext(Object)} cast to a + * DirContextOperations. + * + * @param ctx + * the context to map to an object. + * @return an object built from the data in the context. + */ + protected abstract Object doMapFromContext(DirContextOperations operations); + +}