當前位置: 首頁>>代碼示例>>Java>>正文


Java Beans.getInstanceOf方法代碼示例

本文整理匯總了Java中java.beans.Beans.getInstanceOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Beans.getInstanceOf方法的具體用法?Java Beans.getInstanceOf怎麽用?Java Beans.getInstanceOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.beans.Beans的用法示例。


在下文中一共展示了Beans.getInstanceOf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setValue

import java.beans.Beans; //導入方法依賴的package包/類
public void setValue(T val)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (setter == null) {
        throw new IllegalAccessException();
    }

    Object valideInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());

    try {
        setter.invoke(valideInstance, val);
    } catch (IllegalAccessException ex) {
        try {
            setter.setAccessible(true);
            setter.invoke(valideInstance, val);
        } finally {
            setter.setAccessible(false);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:PropertySupport.java

示例2: setValue

import java.beans.Beans; //導入方法依賴的package包/類
public void setValue(T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canWrite()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());

    Object value = val;
    if (
        (val != null) && (setter.getParameterTypes()[0].getComponentType().isPrimitive()) &&
            (!val.getClass().getComponentType().isPrimitive())
    ) {
        value = Utilities.toPrimitiveArray((Object[]) val);
    }

    setter.invoke(validInstance, value);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:IndexedPropertySupport.java

示例3: getValue

import java.beans.Beans; //導入方法依賴的package包/類
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (getter == null) {
        throw new IllegalAccessException();
    }

    Object valideInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass());

    try {
        try {
            return cast(getValueType(), getter.invoke(valideInstance));
        } catch (IllegalAccessException ex) {
            try {
                getter.setAccessible(true);

                return cast(getValueType(), getter.invoke(valideInstance));
            } finally {
                getter.setAccessible(false);
            }
        }
    } catch (IllegalArgumentException iae) {
        //Provide a better message for debugging
        StringBuffer sb = new StringBuffer("Attempted to invoke method ");
        sb.append(getter.getName());
        sb.append(" from class ");
        sb.append(getter.getDeclaringClass().getName());
        sb.append(" on an instance of ");
        sb.append(valideInstance.getClass().getName());
        sb.append(" Problem:");
        sb.append(iae.getMessage());
        throw (IllegalArgumentException) new IllegalArgumentException(sb.toString()).initCause(iae);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:PropertySupport.java

示例4: destroy

import java.beans.Beans; //導入方法依賴的package包/類
/** Detaches all listeners from the bean and destroys it.
* @throws IOException if there was a problem
*/
@Override
public void destroy() throws IOException {
    if (removePCLMethod != null) {
        try {
            Object o = Beans.getInstanceOf(bean, removePCLMethod.getDeclaringClass());
            removePCLMethod.invoke(o, new Object[] { propertyChangeListener });
        } catch (Exception e) {
            NodeOp.exception(e);
        }
    }

    super.destroy();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:BeanNode.java

示例5: getValue

import java.beans.Beans; //導入方法依賴的package包/類
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canRead()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass());

    return PropertySupport.cast(getValueType(), getter.invoke(validInstance));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:IndexedPropertySupport.java

示例6: getIndexedValue

import java.beans.Beans; //導入方法依賴的package包/類
public E getIndexedValue(int index)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canIndexedRead()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, indexedGetter.getDeclaringClass());

    return PropertySupport.cast(getElementType(), indexedGetter.invoke(validInstance, index));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:IndexedPropertySupport.java

示例7: setIndexedValue

import java.beans.Beans; //導入方法依賴的package包/類
public void setIndexedValue(int index, E val)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canIndexedWrite()) {
        throw new IllegalAccessException();
    }

    Object validInstance = Beans.getInstanceOf(instance, indexedSetter.getDeclaringClass());
    indexedSetter.invoke(validInstance, new Object[] { new Integer(index), val });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:IndexedPropertySupport.java

示例8: testGetInstanceOf

import java.beans.Beans; //導入方法依賴的package包/類
public void testGetInstanceOf() {
    MockJavaBean bean = new MockJavaBean();
    Class<Component> type = Component.class;
    Object obj = Beans.getInstanceOf(bean, type);

    assertSame(bean, obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:8,代碼來源:BeansTest.java

示例9: getValue

import java.beans.Beans; //導入方法依賴的package包/類
public Object getValue () throws
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (getter == null) throw new IllegalAccessException ();
    Object valideInstance = Beans.getInstanceOf (instance, getter.getDeclaringClass());
    try {
        return getter.invoke (valideInstance, new Object [0]);
    } catch (IllegalAccessException ex) {
        try {
            getter.setAccessible(true);
            return getter.invoke (valideInstance, new Object [0]);
        } finally {
            getter.setAccessible(false);
        }
    }
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:16,代碼來源:PropertySupport.java

示例10: setValue

import java.beans.Beans; //導入方法依賴的package包/類
public void setValue (Object val) throws
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (setter == null) throw new IllegalAccessException ();
    Object valideInstance = Beans.getInstanceOf (instance, setter.getDeclaringClass());
    try {
        setter.invoke (valideInstance, new Object [] {val});
    } catch (IllegalAccessException ex) {
        try {
            setter.setAccessible(true); 
            setter.invoke (valideInstance, new Object [] {val});
        } finally {
            setter.setAccessible(false);
        }
    }
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:16,代碼來源:PropertySupport.java

示例11: setValue

import java.beans.Beans; //導入方法依賴的package包/類
public void setValue (Object val) throws
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canWrite ()) throw new IllegalAccessException ();
    Object validInstance = Beans.getInstanceOf (instance, setter.getDeclaringClass());
    if ((val!=null)&&(setter.getParameterTypes()[0].getComponentType().isPrimitive())&&(!val.getClass().getComponentType().isPrimitive())) {
        val = Utilities.toPrimitiveArray ((Object[])val);
    }
    setter.invoke (validInstance, new Object [] {val});
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:10,代碼來源:IndexedPropertySupport.java

示例12: testGetInstanceOf_BeanNull

import java.beans.Beans; //導入方法依賴的package包/類
public void testGetInstanceOf_BeanNull() {
    Class<Component> type = Component.class;
    Object obj = Beans.getInstanceOf(null, type);

    assertNull(obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:7,代碼來源:BeansTest.java

示例13: testGetInstanceOf_TargetTypeNull

import java.beans.Beans; //導入方法依賴的package包/類
public void testGetInstanceOf_TargetTypeNull() {
    MockJavaBean bean = new MockJavaBean();
    Object obj = Beans.getInstanceOf(bean, null);

    assertSame(bean, obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:7,代碼來源:BeansTest.java

示例14: getValue

import java.beans.Beans; //導入方法依賴的package包/類
public Object getValue () throws
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canRead ()) throw new IllegalAccessException ();
    Object validInstance = Beans.getInstanceOf (instance, getter.getDeclaringClass());
    return getter.invoke (validInstance, new Object [0]);
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:7,代碼來源:IndexedPropertySupport.java

示例15: getIndexedValue

import java.beans.Beans; //導入方法依賴的package包/類
public Object getIndexedValue (int index) throws
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!canIndexedRead ()) throw new IllegalAccessException ();
    Object validInstance = Beans.getInstanceOf (instance, indexedGetter.getDeclaringClass());
    return indexedGetter.invoke (validInstance, new Object [] {new Integer (index)});
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:7,代碼來源:IndexedPropertySupport.java


注:本文中的java.beans.Beans.getInstanceOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。