001    package org.apache.commons.digester3.annotations.rules;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.lang.annotation.Documented;
023    import java.lang.annotation.ElementType;
024    import java.lang.annotation.Retention;
025    import java.lang.annotation.RetentionPolicy;
026    import java.lang.annotation.Target;
027    
028    import org.apache.commons.digester3.ObjectCreateRule;
029    import org.apache.commons.digester3.annotations.DigesterRule;
030    import org.apache.commons.digester3.annotations.DigesterRuleList;
031    import org.apache.commons.digester3.annotations.handlers.ObjectCreateHandler;
032    
033    /**
034     * Classes annotated with {@code ObjectCreate} will be bound with {@code ObjectCreateRule} digester rule.
035     *
036     * @see org.apache.commons.digester3.Digester#addObjectCreate(String,Class)
037     * @since 2.1
038     */
039    @Documented
040    @Retention( RetentionPolicy.RUNTIME )
041    @Target( { ElementType.CONSTRUCTOR, ElementType.TYPE } )
042    @CreationRule
043    @DigesterRule( reflectsRule = ObjectCreateRule.class, handledBy = ObjectCreateHandler.class )
044    public @interface ObjectCreate
045    {
046    
047        /**
048         * The element matching pattern.
049         */
050        String pattern();
051    
052        /**
053         * The namespace URI for which this Rule is relevant, if any.
054         *
055         * @since 3.0
056         */
057        String namespaceURI() default "";
058    
059        /**
060         * Allows specify the attribute containing an override class name if it is present.
061         *
062         * @since 3.0
063         */
064        String attributeName() default "";
065    
066        /**
067         * Defines several {@code @ObjectCreate} annotations on the same element.
068         *
069         * @see ObjectCreate
070         */
071        @Documented
072        @Retention( RetentionPolicy.RUNTIME )
073        @Target( ElementType.TYPE )
074        @DigesterRuleList
075        @interface List
076        {
077            ObjectCreate[] value();
078        }
079    
080    }