com.github.miemiedev.mybatis.paginator.support
类 PropertiesHelper

java.lang.Object
  继承者 com.github.miemiedev.mybatis.paginator.support.PropertiesHelper

public class PropertiesHelper
extends Object

Properties的操作的工具类,为Properties提供一个代理增加相关工具方法如 getRequiredString(),getInt(),getBoolean()等方法 并可以通过systemPropertiesMode属性指定是否搜索System.getProperty()及System.getenv()来查找值. 默认不搜索系统属性

 使用1:
 public class ConnectionUtils {
     static Properties properties = new Properties(); 
     // ... do load properties 
     
     // delegate to properties
           static PropertiesHelper props = new PropertiesHelper(properties);
     public static Connection getConnection() {
                // use getRequiredProperty() 
                DriverManager.getConnection(props.getRequiredString("jdbc.url"));
     }
 }
 指定是否搜索系统属性:
 new PropertiesHelper(properties,PropertiesHelper.SYSTEM_PROPERTIES_MODE_OVERRIDE)
 

作者:
badqiu

字段摘要
static int SYSTEM_PROPERTIES_MODE_FALLBACK
          Check system properties if not resolvable in the specified properties.
static int SYSTEM_PROPERTIES_MODE_NEVER
          Never check system properties.
static int SYSTEM_PROPERTIES_MODE_OVERRIDE
          Check system properties first, before trying the specified properties.
 
构造方法摘要
PropertiesHelper(Properties p)
           
PropertiesHelper(Properties p, int systemPropertiesMode)
           
 
方法摘要
 void clear()
           
 boolean contains(Object value)
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Enumeration<Object> elements()
           
 Set<Map.Entry<Object,Object>> entrySet()
           
 Object get(Object key)
           
 String getAndTryFromSystem(String key)
          尝试从System.getProperty(key)及System.getenv(key)得到值
 Boolean getBoolean(String key)
           
 boolean getBoolean(String key, boolean defaultValue)
           
 Double getDouble(String key)
           
 double getDouble(String key, double defaultValue)
           
 Float getFloat(String key)
           
 float getFloat(String key, float defaultValue)
           
 int getInt(String key, int defaultValue)
           
 int[] getIntArray(String key)
           
 Integer getInteger(String key)
           
 Long getLong(String key)
           
 long getLong(String key, long defaultValue)
           
 String getNullIfBlank(String key)
           
 String getNullIfEmpty(String key)
           
 Properties getProperties()
           
 String getProperty(String key)
           
 String getProperty(String key, String defaultValue)
          delegate method start
 boolean getRequiredBoolean(String key)
           
 Double getRequiredDouble(String key)
           
 Float getRequiredFloat(String key)
           
 int getRequiredInt(String key)
           
 Long getRequiredLong(String key)
           
 String getRequiredString(String key)
           
 Properties getStartsWithProperties(String prefix)
           
 String[] getStringArray(String key)
           
 boolean isEmpty()
           
 Enumeration<Object> keys()
           
 Set<Object> keySet()
           
 void list(PrintStream out)
           
 void list(PrintWriter out)
           
 void load(InputStream inStream)
           
 void loadFromXML(InputStream in)
           
 Enumeration<?> propertyNames()
           
 Object put(Object key, Object value)
           
 void putAll(Map<? extends Object,? extends Object> t)
           
 Object remove(Object key)
           
 void save(OutputStream out, String comments)
          已过时。  
 void setProperties(Properties props)
           
 Object setProperty(String key, boolean value)
           
 Object setProperty(String key, double value)
           
 Object setProperty(String key, float value)
           
 Object setProperty(String key, int value)
          setProperty(String key,int value) ... start
 Object setProperty(String key, long value)
           
 Object setProperty(String key, String value)
           
 int size()
           
 void store(OutputStream out, String comments)
           
 void storeToXML(OutputStream os, String comment)
           
 void storeToXML(OutputStream os, String comment, String encoding)
           
 String toString()
           
 Collection<Object> values()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

SYSTEM_PROPERTIES_MODE_NEVER

public static final int SYSTEM_PROPERTIES_MODE_NEVER
Never check system properties.

另请参见:
常量字段值

SYSTEM_PROPERTIES_MODE_FALLBACK

public static final int SYSTEM_PROPERTIES_MODE_FALLBACK
Check system properties if not resolvable in the specified properties. This is the default.

另请参见:
常量字段值

SYSTEM_PROPERTIES_MODE_OVERRIDE

public static final int SYSTEM_PROPERTIES_MODE_OVERRIDE
Check system properties first, before trying the specified properties. This allows system properties to override any other property source.

另请参见:
常量字段值
构造方法详细信息

PropertiesHelper

public PropertiesHelper(Properties p)

PropertiesHelper

public PropertiesHelper(Properties p,
                        int systemPropertiesMode)
方法详细信息

getProperties

public Properties getProperties()

setProperties

public void setProperties(Properties props)

getRequiredString

public String getRequiredString(String key)

getNullIfBlank

public String getNullIfBlank(String key)

getNullIfEmpty

public String getNullIfEmpty(String key)

getAndTryFromSystem

public String getAndTryFromSystem(String key)
尝试从System.getProperty(key)及System.getenv(key)得到值

返回:

getInteger

public Integer getInteger(String key)

getInt

public int getInt(String key,
                  int defaultValue)

getRequiredInt

public int getRequiredInt(String key)

getLong

public Long getLong(String key)

getLong

public long getLong(String key,
                    long defaultValue)

getRequiredLong

public Long getRequiredLong(String key)

getBoolean

public Boolean getBoolean(String key)

getBoolean

public boolean getBoolean(String key,
                          boolean defaultValue)

getRequiredBoolean

public boolean getRequiredBoolean(String key)

getFloat

public Float getFloat(String key)

getFloat

public float getFloat(String key,
                      float defaultValue)

getRequiredFloat

public Float getRequiredFloat(String key)

getDouble

public Double getDouble(String key)

getDouble

public double getDouble(String key,
                        double defaultValue)

getRequiredDouble

public Double getRequiredDouble(String key)

setProperty

public Object setProperty(String key,
                          int value)
setProperty(String key,int value) ... start


setProperty

public Object setProperty(String key,
                          long value)

setProperty

public Object setProperty(String key,
                          float value)

setProperty

public Object setProperty(String key,
                          double value)

setProperty

public Object setProperty(String key,
                          boolean value)

getStringArray

public String[] getStringArray(String key)

getIntArray

public int[] getIntArray(String key)

getStartsWithProperties

public Properties getStartsWithProperties(String prefix)

getProperty

public String getProperty(String key,
                          String defaultValue)
delegate method start


getProperty

public String getProperty(String key)

setProperty

public Object setProperty(String key,
                          String value)

clear

public void clear()

entrySet

public Set<Map.Entry<Object,Object>> entrySet()

propertyNames

public Enumeration<?> propertyNames()

contains

public boolean contains(Object value)

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

elements

public Enumeration<Object> elements()

get

public Object get(Object key)

isEmpty

public boolean isEmpty()

keys

public Enumeration<Object> keys()

keySet

public Set<Object> keySet()

list

public void list(PrintStream out)

list

public void list(PrintWriter out)

load

public void load(InputStream inStream)
          throws IOException
抛出:
IOException

loadFromXML

public void loadFromXML(InputStream in)
                 throws IOException,
                        InvalidPropertiesFormatException
抛出:
IOException
InvalidPropertiesFormatException

put

public Object put(Object key,
                  Object value)

putAll

public void putAll(Map<? extends Object,? extends Object> t)

remove

public Object remove(Object key)

save

public void save(OutputStream out,
                 String comments)
已过时。 


size

public int size()

store

public void store(OutputStream out,
                  String comments)
           throws IOException
抛出:
IOException

storeToXML

public void storeToXML(OutputStream os,
                       String comment,
                       String encoding)
                throws IOException
抛出:
IOException

storeToXML

public void storeToXML(OutputStream os,
                       String comment)
                throws IOException
抛出:
IOException

values

public Collection<Object> values()

toString

public String toString()
覆盖:
Object 中的 toString


Copyright © 2015. All rights reserved.