⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpletypemapper.java

📁 JAVA 文章管理系统源码
💻 JAVA
字号:
/*
 * Copyright 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.commons.betwixt.strategy;

import org.apache.commons.betwixt.IntrospectionConfiguration;

/**
 * Strategy for binding simple types.
 * Simple types (in xml) have no attributes or child elements.
 * For Betwixt, these are converted to and from strings
 * and these strings used to populate either attributes or element body's.
 * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
 * @version $Revision: 1.2 $
 */
public abstract class SimpleTypeMapper {

    /**
     * Enumerates binding options for simple types.
     * Simple types (in xml) have no attributes or child elements.
     * For Betwixt, these are converted to and from strings
     * and these strings used to populate either attributes or element body's.
     * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
     * @version $Revision: 1.2 $
     */
    public static class Binding {
        public static final Binding ELEMENT = new Binding(1);
        public static final Binding ATTRIBUTE = new Binding(2);
        
        private static final int ELEMENT_CODE = 1;
        private static final int ATTRIBUTE_CODE = 2;
        
        private int code;
        private Binding(int code) {
            this.code = code;
        }
        
        
        /**
         * Equals compatible with the enumeration.
         */
        public boolean equals( Object obj ) {
            boolean result = false;
            if ( obj == this ) {
                result = true; 
            }
            return result;
        }

        /**
         * Implementation compatible with equals
         */
        public int hashCode() {
            return code;
        }

        /**
         * Generate something appropriate for logging.
         */
        public String toString() {
            String result = "[Binding]";
            switch (code) {
                case ELEMENT_CODE:
                    result = "[Binding: ELEMENT]";
                    break;
                    
                case ATTRIBUTE_CODE:
                    result = "[Binding: ATTRIBUTE]";
                    break;
            }   
            return result;
        }
    }
    
    /**
     * <p>Specifies the binding of a simple type.
     * </p><p>
     * <strong>Note:</strong> the xml name to which this property will be bound
     * cannot be known at this stage (since it depends
     * </p>
     * @param propertyName the name of the property (to be bound)
     * @param propertyType the type of the property (to be bound)
     * @param configuration the current IntrospectionConfiguration
     */
    public abstract SimpleTypeMapper.Binding bind(
                                                String propertyName, 
                                                Class propertyType, 
                                                IntrospectionConfiguration configuration);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -