private synchronized void makePropertyDescriptors() { if (propertyDescriptors != null) return; // javaClassRef is a WeakReference. So, our javaClass may have been GC'ed. // Protect against this case... Class javaClass = (Class)javaClassRef.get(); if (javaClass == null) { // could throw a RuntimeException, but instead log error and dummy up descriptors log.error(Messages.getMessage("classGCed")); propertyDescriptors = new BeanPropertyDescriptor[0]; anyDesc = null; lookedForAny = true; return; } propertyDescriptors = BeanUtils.getPd(javaClass, this); if (!lookedForAny) { anyDesc = BeanUtils.getAnyContentPD(javaClass); lookedForAny = true; } }
public static BeanPropertyDescriptor getAnyContentPD(Class javaType) { PropertyDescriptor [] pds = getPropertyDescriptors(javaType); return getSpecificPD(pds, Constants.ANYCONTENT); }
/** * Create a BeanPropertyDescriptor array for the indicated class. * @param javaType * @param typeDesc * @return an ordered array of properties */ public static BeanPropertyDescriptor[] getPd(Class javaType, TypeDesc typeDesc) { BeanPropertyDescriptor[] pd; try { final Class secJavaType = javaType; // Need doPrivileged access to do introspection. PropertyDescriptor[] rawPd = getPropertyDescriptors(secJavaType); pd = processPropertyDescriptors(rawPd,javaType,typeDesc); } catch (Exception e) { // this should never happen throw new InternalException(e); } return pd; }
/** * Create a BeanPropertyDescriptor array for the indicated class. * @param javaType * @return an ordered array of properties */ public static BeanPropertyDescriptor[] getPd(Class javaType) { return getPd(javaType, null); }
private void initConstructor(Class javaType) { if (!this.isBasicType) { // discover the constructor for non basic types try { if (QName.class.isAssignableFrom(javaType)) { constructor = javaType.getDeclaredConstructor(STRING_STRING_CLASS); } else { constructor = javaType.getDeclaredConstructor(STRING_CLASS); } } catch (NoSuchMethodException e) { try { constructor = javaType.getDeclaredConstructor(new Class[]{}); BeanPropertyDescriptor[] pds = BeanUtils.getPd(javaType); if(pds != null) { if(BeanUtils.getSpecificPD(pds,"_value")!=null){ return; } } throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException(ex.toString()); } } } }
public BeanPropertyDescriptor getAnyContentDescriptor() { if (!lookedForAny) { // javaClassRef is a WeakReference. So, our javaClass may have been GC'ed. // Protect against this case... Class javaClass = (Class)javaClassRef.get(); if (javaClass != null) { anyDesc = BeanUtils.getAnyContentPD(javaClass); } else { log.error(Messages.getMessage("classGCed")); anyDesc = null; } lookedForAny = true; } return anyDesc; }
BeanPropertyDescriptor pd = BeanUtils.getSpecificPD(propertyDescriptor, "_value"); if(pd != null) { try {
public static BeanPropertyDescriptor[] processPropertyDescriptors( PropertyDescriptor[] rawPd, Class cls, TypeDesc typeDesc) { // Create a copy of the rawPd called myPd BeanPropertyDescriptor[] myPd = new BeanPropertyDescriptor[rawPd.length]; ArrayList pd = new ArrayList(); try { for (int i=0; i < rawPd.length; i++) { // Skip the special "any" field if (rawPd[i].getName().equals(Constants.ANYCONTENT)) continue; pd.add(new BeanPropertyDescriptor(rawPd[i])); } // Now look for public fields Field fields[] = cls.getFields(); if (fields != null && fields.length > 0) { // See if the field is in the list of properties // add it if not. for (int i=0; i < fields.length; i++) { Field f = fields[i]; // skip if field come from a java.* or javax.* package // WARNING: Is this going to make bad things happen for // users JavaBeans? Do they WANT these fields serialzed? String clsName = f.getDeclaringClass().getName(); if (clsName.startsWith("java.") || clsName.startsWith("javax.")) { continue;
/** * Create a BeanPropertyDescriptor array for the indicated class. * @param javaType * @return an ordered array of properties */ public static BeanPropertyDescriptor[] getPd(Class javaType) { return getPd(javaType, null); }
private void initConstructor(Class javaType) { if (!this.isBasicType) { // discover the constructor for non basic types try { if (QName.class.isAssignableFrom(javaType)) { constructor = javaType.getDeclaredConstructor(STRING_STRING_CLASS); } else { constructor = javaType.getDeclaredConstructor(STRING_CLASS); } } catch (NoSuchMethodException e) { try { constructor = javaType.getDeclaredConstructor(new Class[]{}); BeanPropertyDescriptor[] pds = BeanUtils.getPd(javaType); if(pds != null) { if(BeanUtils.getSpecificPD(pds,"_value")!=null){ return; } } throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException(ex.toString()); } } } }
public BeanPropertyDescriptor getAnyContentDescriptor() { if (!lookedForAny) { // javaClassRef is a WeakReference. So, our javaClass may have been GC'ed. // Protect against this case... Class javaClass = (Class)javaClassRef.get(); if (javaClass != null) { anyDesc = BeanUtils.getAnyContentPD(javaClass); } else { log.error(Messages.getMessage("classGCed")); anyDesc = null; } lookedForAny = true; } return anyDesc; }
BeanPropertyDescriptor pd = BeanUtils.getSpecificPD(propertyDescriptor, "_value"); if(pd != null) { try {
public static BeanPropertyDescriptor[] processPropertyDescriptors( PropertyDescriptor[] rawPd, Class cls, TypeDesc typeDesc) { // Create a copy of the rawPd called myPd BeanPropertyDescriptor[] myPd = new BeanPropertyDescriptor[rawPd.length]; ArrayList pd = new ArrayList(); try { for (int i=0; i < rawPd.length; i++) { // Skip the special "any" field if (rawPd[i].getName().equals(Constants.ANYCONTENT)) continue; pd.add(new BeanPropertyDescriptor(rawPd[i])); } // Now look for public fields Field fields[] = cls.getFields(); if (fields != null && fields.length > 0) { // See if the field is in the list of properties // add it if not. for (int i=0; i < fields.length; i++) { Field f = fields[i]; // skip if field come from a java.* or javax.* package // WARNING: Is this going to make bad things happen for // users JavaBeans? Do they WANT these fields serialzed? String clsName = f.getDeclaringClass().getName(); if (clsName.startsWith("java.") || clsName.startsWith("javax.")) { continue;
/** * Create a BeanPropertyDescriptor array for the indicated class. * @param javaType * @return an ordered array of properties */ public static BeanPropertyDescriptor[] getPd(Class javaType) { return getPd(javaType, null); }
public static BeanPropertyDescriptor getAnyContentPD(Class javaType) { PropertyDescriptor [] pds = getPropertyDescriptors(javaType); return getSpecificPD(pds, Constants.ANYCONTENT); }
/** * Create a BeanPropertyDescriptor array for the indicated class. * @param javaType * @param typeDesc * @return an ordered array of properties */ public static BeanPropertyDescriptor[] getPd(Class javaType, TypeDesc typeDesc) { BeanPropertyDescriptor[] pd; try { final Class secJavaType = javaType; // Need doPrivileged access to do introspection. PropertyDescriptor[] rawPd = getPropertyDescriptors(secJavaType); pd = processPropertyDescriptors(rawPd,javaType,typeDesc); } catch (Exception e) { // this should never happen throw new InternalException(e); } return pd; }
private synchronized void makePropertyDescriptors() { if (propertyDescriptors != null) return; // javaClassRef is a WeakReference. So, our javaClass may have been GC'ed. // Protect against this case... Class javaClass = (Class)javaClassRef.get(); if (javaClass == null) { // could throw a RuntimeException, but instead log error and dummy up descriptors log.error(Messages.getMessage("classGCed")); propertyDescriptors = new BeanPropertyDescriptor[0]; anyDesc = null; lookedForAny = true; return; } propertyDescriptors = BeanUtils.getPd(javaClass, this); if (!lookedForAny) { anyDesc = BeanUtils.getAnyContentPD(javaClass); lookedForAny = true; } }
private void initConstructor(Class javaType) { if (!this.isBasicType) { // discover the constructor for non basic types try { if (QName.class.isAssignableFrom(javaType)) { constructor = javaType.getDeclaredConstructor(STRING_STRING_CLASS); } else { constructor = javaType.getDeclaredConstructor(STRING_CLASS); } } catch (NoSuchMethodException e) { try { constructor = javaType.getDeclaredConstructor(new Class[]{}); BeanPropertyDescriptor[] pds = BeanUtils.getPd(javaType); if(pds != null) { if(BeanUtils.getSpecificPD(pds,"_value")!=null){ return; } } throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException(ex.toString()); } } } }
public BeanPropertyDescriptor getAnyContentDescriptor() { if (!lookedForAny) { // javaClassRef is a WeakReference. So, our javaClass may have been GC'ed. // Protect against this case... Class javaClass = (Class)javaClassRef.get(); if (javaClass != null) { anyDesc = BeanUtils.getAnyContentPD(javaClass); } else { log.error(Messages.getMessage("classGCed")); anyDesc = null; } lookedForAny = true; } return anyDesc; }
BeanPropertyDescriptor pd = BeanUtils.getSpecificPD(propertyDescriptor, "_value"); if(pd != null) { try {