![]() |
![]() |
com.sun.syndication_0.9.0.v20080306181116:34:33.417 INFO jd.cli.Main - Decompiling com.sun.syndication_0.9.0.v200803061811.jar package com.sun.syndication.feed; public abstract interface CopyFrom { public abstract Class getInterface(); public abstract void copyFrom(Object paramObject); } /* Location: * Qualified Name: com.sun.syndication.feed.CopyFrom * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; import java.io.Serializable; import java.util.ArrayList; import java.util.List; public abstract class WireFeed implements Cloneable, Serializable, Extendable { private ObjectBean _objBean; private String _feedType; private String _encoding; private List _modules; private List _foreignMarkup; protected WireFeed() { _objBean = new ObjectBean(getClass(), this); } protected WireFeed(String type) { this(); _feedType = type; } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { Object fm = getForeignMarkup(); setForeignMarkup(((WireFeed)other).getForeignMarkup()); boolean ret = _objBean.equals(other); setForeignMarkup(fm); return ret; } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public void setFeedType(String feedType) { _feedType = feedType; } public String getFeedType() { return _feedType; } public String getEncoding() { return _encoding; } public void setEncoding(String encoding) { _encoding = encoding; } public List getModules() { return _modules == null ? (_modules = new ArrayList()) : _modules; } public void setModules(List modules) { _modules = modules; } public Module getModule(String uri) { return ModuleUtils.getModule(_modules, uri); } public Object getForeignMarkup() { return _foreignMarkup == null ? (_foreignMarkup = new ArrayList()) : _foreignMarkup; } public void setForeignMarkup(Object foreignMarkup) { _foreignMarkup = ((List)foreignMarkup); } } /* Location: * Qualified Name: com.sun.syndication.feed.WireFeed * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; public class Category implements Cloneable, Serializable { private ObjectBean _objBean; private String _term; private String _scheme; private String _label; public Category() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { return _objBean.equals(other); } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getLabel() { return _label; } public void setLabel(String label) { _label = label; } public String getScheme() { return _scheme; } public void setScheme(String scheme) { _scheme = scheme; } public String getTerm() { return _term; } public void setTerm(String term) { _term = term; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Category * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; import java.util.HashSet; import java.util.Set; public class Content implements Cloneable, Serializable { private ObjectBean _objBean; private String _type; private String _value; private String _src; public static final String TEXT = "text"; public static final String HTML = "html"; public static final String XHTML = "xhtml"; public static final String XML = "xml"; public static final String BASE64 = "base64"; public static final String ESCAPED = "escaped"; private String _mode; private static final Set MODES = new HashSet(); static { MODES.add("xml"); MODES.add("base64"); MODES.add("escaped"); } public Content() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { return _objBean.equals(other); } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getType() { return _type; } public void setType(String type) { _type = type; } public String getMode() { return _mode; } public void setMode(String mode) { mode = mode != null ? mode.toLowerCase() : null; if ((mode == null) || (!MODES.contains(mode))) { throw new IllegalArgumentException("Invalid mode [" + mode + "]"); } _mode = mode; } public String getValue() { return _value; } public void setValue(String value) { _value = value; } public String getSrc() { return _src; } public void setSrc(String src) { _src = src; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Content * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Entry implements Cloneable, Serializable, Extendable { private ObjectBean _objBean; private String _xmlBase; private List _authors; private List _contributors; private List _categories; private List _contents; private String _id; private Date _published; private String _rights; private Feed _source; private Content _summary; private Content _title; private Date _updated; private List _alternateLinks; private List _otherLinks; private List _foreignMarkup; private List _modules; private Date _created; public Entry() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { Object fm = getForeignMarkup(); setForeignMarkup(((Entry)other).getForeignMarkup()); boolean ret = _objBean.equals(other); setForeignMarkup(fm); return ret; } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getTitle() { if (_title != null) { return _title.getValue(); } return null; } public void setTitle(String title) { if (_title == null) { _title = new Content(); } _title.setValue(title); } public Content getTitleEx() { return _title; } public void setTitleEx(Content title) { _title = title; } public List getAlternateLinks() { return _alternateLinks == null ? (_alternateLinks = new ArrayList()) : _alternateLinks; } public void setAlternateLinks(List alternateLinks) { _alternateLinks = alternateLinks; } public List getOtherLinks() { return _otherLinks == null ? (_otherLinks = new ArrayList()) : _otherLinks; } public void setOtherLinks(List otherLinks) { _otherLinks = otherLinks; } public List getAuthors() { return _authors; } public void setAuthors(List authors) { _authors = authors; } public List getContributors() { return _contributors == null ? (_contributors = new ArrayList()) : _contributors; } public void setContributors(List contributors) { _contributors = contributors; } public String getId() { return _id; } public void setId(String id) { _id = id; } public Date getModified() { return _updated; } public void setModified(Date modified) { _updated = modified; } public Date getIssued() { return _published; } public void setIssued(Date issued) { _published = issued; } public Date getCreated() { return _created; } public void setCreated(Date created) { _created = created; } public Content getSummary() { return _summary; } public void setSummary(Content summary) { _summary = summary; } public List getContents() { return _contents == null ? (_contents = new ArrayList()) : _contents; } public void setContents(List contents) { _contents = contents; } public List getModules() { return _modules == null ? (_modules = new ArrayList()) : _modules; } public void setModules(List modules) { _modules = modules; } public Module getModule(String uri) { return ModuleUtils.getModule(_modules, uri); } public Date getPublished() { return _published; } public void setPublished(Date published) { _published = published; } public String getRights() { return _rights; } public void setRights(String rights) { _rights = rights; } public Feed getSource() { return _source; } public void setSource(Feed source) { _source = source; } public Date getUpdated() { return _updated; } public void setUpdated(Date updated) { _updated = updated; } public List getCategories() { return _categories; } public void setCategories(List categories) { _categories = categories; } public String getXmlBase() { return _xmlBase; } public void setXmlBase(String xmlBase) { _xmlBase = xmlBase; } public Object getForeignMarkup() { return _foreignMarkup == null ? (_foreignMarkup = new ArrayList()) : _foreignMarkup; } public void setForeignMarkup(Object foreignMarkup) { _foreignMarkup = ((List)foreignMarkup); } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Entry * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Feed extends WireFeed { private String _xmlBase; private List _categories; private List _authors; private List _contributors; private Generator _generator; private String _icon; private String _id; private String _logo; private String _rights; private Content _subtitle; private Content _title; private Date _updated; private List _alternateLinks; private List _otherLinks; private List _entries; private List _modules; private Content _info; private String _language; public Feed() {} public Feed(String type) { super(type); } public String getLanguage() { return _language; } public void setLanguage(String language) { _language = language; } public String getTitle() { if (_title != null) { return _title.getValue(); } return null; } public void setTitle(String title) { if (_title == null) { _title = new Content(); } _title.setValue(title); } public Content getTitleEx() { return _title; } public void setTitleEx(Content title) { _title = title; } public List getAlternateLinks() { return _alternateLinks == null ? (_alternateLinks = new ArrayList()) : _alternateLinks; } public void setAlternateLinks(List alternateLinks) { _alternateLinks = alternateLinks; } public List getOtherLinks() { return _otherLinks == null ? (_otherLinks = new ArrayList()) : _otherLinks; } public void setOtherLinks(List otherLinks) { _otherLinks = otherLinks; } public List getAuthors() { return _authors == null ? (_authors = new ArrayList()) : _authors; } public void setAuthors(List authors) { _authors = authors; } public List getContributors() { return _contributors == null ? (_contributors = new ArrayList()) : _contributors; } public void setContributors(List contributors) { _contributors = contributors; } public Content getTagline() { return _subtitle; } public void setTagline(Content tagline) { _subtitle = tagline; } public String getId() { return _id; } public void setId(String id) { _id = id; } public Generator getGenerator() { return _generator; } public void setGenerator(Generator generator) { _generator = generator; } public String getCopyright() { return _rights; } public void setCopyright(String copyright) { _rights = copyright; } public Content getInfo() { return _info; } public void setInfo(Content info) { _info = info; } public Date getModified() { return _updated; } public void setModified(Date modified) { _updated = modified; } public List getEntries() { return _entries == null ? (_entries = new ArrayList()) : _entries; } public void setEntries(List entries) { _entries = entries; } public List getModules() { return _modules == null ? (_modules = new ArrayList()) : _modules; } public void setModules(List modules) { _modules = modules; } public Module getModule(String uri) { return ModuleUtils.getModule(_modules, uri); } public List getCategories() { return _categories; } public void setCategories(List categories) { _categories = categories; } public String getIcon() { return _icon; } public void setIcon(String icon) { _icon = icon; } public String getLogo() { return _logo; } public void setLogo(String logo) { _logo = logo; } public String getRights() { return _rights; } public void setRights(String rights) { _rights = rights; } public Content getSubtitle() { return _subtitle; } public void setSubtitle(Content subtitle) { _subtitle = subtitle; } public Date getUpdated() { return _updated; } public void setUpdated(Date updated) { _updated = updated; } public String getXmlBase() { return _xmlBase; } public void setXmlBase(String xmlBase) { _xmlBase = xmlBase; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Feed * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; public class Generator implements Cloneable, Serializable { private ObjectBean _objBean; private String _url; private String _version; private String _value; public Generator() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { return _objBean.equals(other); } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getUrl() { return _url; } public void setUrl(String url) { _url = url; } public String getVersion() { return _version; } public void setVersion(String version) { _version = version; } public String getValue() { return _value; } public void setValue(String value) { _value = value; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Generator * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; public class Link implements Cloneable, Serializable { private ObjectBean _objBean; private String _href; private String _rel = "alternate"; private String _type; private String _hreflang; private String _title; private long _length; public Link() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { return _objBean.equals(other); } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getRel() { return _rel; } public void setRel(String rel) { _rel = rel; } public String getType() { return _type; } public void setType(String type) { _type = type; } public String getHref() { return _href; } public void setHref(String href) { _href = href; } public String getTitle() { return _title; } public void setTitle(String title) { _title = title; } public String getHreflang() { return _hreflang; } public void setHreflang(String hreflang) { _hreflang = hreflang; } public long getLength() { return _length; } public void setLength(long length) { _length = length; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Link * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.atom; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; public class Person implements Cloneable, Serializable { private ObjectBean _objBean; private String _name; private String _uri; private String _email; public Person() { _objBean = new ObjectBean(getClass(), this); } public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } public boolean equals(Object other) { return _objBean.equals(other); } public int hashCode() { return _objBean.hashCode(); } public String toString() { return _objBean.toString(); } public String getName() { return _name; } public void setName(String name) { _name = name; } public String getUrl() { return _uri; } public void setUrl(String url) { _uri = url; } public String getEmail() { return _email; } public void setEmail(String email) { _email = email; } public String getUri() { return _uri; } public void setUri(String uri) { _uri = uri; } } /* Location: * Qualified Name: com.sun.syndication.feed.atom.Person * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class BeanIntrospector { private static final Map _introspected = new HashMap(); private static final String SETTER = "set"; private static final String GETTER = "get"; private static final String BOOLEAN_GETTER = "is"; public static synchronized PropertyDescriptor[] getPropertyDescriptors(Class klass) throws IntrospectionException { PropertyDescriptor[] descriptors = (PropertyDescriptor[])_introspected.get(klass); if (descriptors == null) { descriptors = getPDs(klass); _introspected.put(klass, descriptors); } return descriptors; } private static PropertyDescriptor[] getPDs(Class klass) throws IntrospectionException { Method[] methods = klass.getMethods(); Map getters = getPDs(methods, false); Map setters = getPDs(methods, true); List pds = merge(getters, setters); PropertyDescriptor[] array = new PropertyDescriptor[pds.size()]; pds.toArray(array); return array; } private static Map getPDs(Method[] methods, boolean setters) throws IntrospectionException { Map pds = new HashMap(); for (int i = 0; i < methods.length; i++) { String pName = null; PropertyDescriptor pDescriptor = null; if ((methods[i].getModifiers() & 0x1) != 0) { if (setters) { if ((methods[i].getName().startsWith("set")) && (methods[i].getReturnType() == Void.TYPE) && (methods[i].getParameterTypes().length == 1)) { pName = Introspector.decapitalize(methods[i].getName().substring(3)); pDescriptor = new PropertyDescriptor(pName, null, methods[i]); } } else if ((methods[i].getName().startsWith("get")) && (methods[i].getReturnType() != Void.TYPE) && (methods[i].getParameterTypes().length == 0)) { pName = Introspector.decapitalize(methods[i].getName().substring(3)); pDescriptor = new PropertyDescriptor(pName, methods[i], null); } else if ((methods[i].getName().startsWith("is")) && (methods[i].getReturnType() == Boolean.TYPE) && (methods[i].getParameterTypes().length == 0)) { pName = Introspector.decapitalize(methods[i].getName().substring(2)); pDescriptor = new PropertyDescriptor(pName, methods[i], null); } } if (pName != null) { pds.put(pName, pDescriptor); } } return pds; } private static List merge(Map getters, Map setters) throws IntrospectionException { List props = new ArrayList(); Set processedProps = new HashSet(); Iterator gs = getters.keySet().iterator(); while (gs.hasNext()) { String name = (String)gs.next(); PropertyDescriptor getter = (PropertyDescriptor)getters.get(name); PropertyDescriptor setter = (PropertyDescriptor)setters.get(name); if (setter != null) { processedProps.add(name); PropertyDescriptor prop = new PropertyDescriptor(name, getter.getReadMethod(), setter.getWriteMethod()); props.add(prop); } else { props.add(getter); } } Set writeOnlyProps = new HashSet(setters.keySet()); writeOnlyProps.removeAll(processedProps); Iterator ss = writeOnlyProps.iterator(); while (ss.hasNext()) { String name = (String)ss.next(); PropertyDescriptor setter = (PropertyDescriptor)setters.get(name); props.add(setter); } return props; } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.BeanIntrospector * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.beans.PropertyDescriptor; import java.io.PrintStream; import java.io.Serializable; import java.lang.reflect.Array; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class CloneableBean implements Serializable, Cloneable { private static final Class[] NO_PARAMS_DEF = new Class[0]; private static final Object[] NO_PARAMS = new Object[0]; private Object _obj; private Set _ignoreProperties; protected CloneableBean() { _obj = this; } public CloneableBean(Object obj) { this(obj, null); } public CloneableBean(Object obj, Set ignoreProperties) { _obj = obj; _ignoreProperties = (ignoreProperties != null ? ignoreProperties : Collections.EMPTY_SET); } public Object clone() throws CloneNotSupportedException { return beanClone(); } public Object beanClone() throws CloneNotSupportedException { try { Object clonedBean = _obj.getClass().newInstance(); PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_obj.getClass()); if (pds != null) { for (int i = 0; i < pds.length; i++) { Method pReadMethod = pds[i].getReadMethod(); Method pWriteMethod = pds[i].getWriteMethod(); if ((pReadMethod != null) && (pWriteMethod != null) && (!_ignoreProperties.contains(pds[i].getName())) && (pReadMethod.getDeclaringClass() != Object.class) && (pReadMethod.getParameterTypes().length == 0)) { Object value = pReadMethod.invoke(_obj, NO_PARAMS); if (value != null) { value = doClone(value); pWriteMethod.invoke(clonedBean, new Object[] { value }); } } } } } catch (CloneNotSupportedException cnsEx) { throw cnsEx; } catch (Exception ex) { System.out.println(ex); ex.printStackTrace(System.out); throw new CloneNotSupportedException("Cannot clone a " + _obj.getClass() + " object"); } Object clonedBean; return clonedBean; } private Object doClone(Object value) throws Exception { if (value != null) { Class vClass = value.getClass(); if (vClass.isArray()) { value = cloneArray(value); } else if ((value instanceof Collection)) { value = cloneCollection((Collection)value); } else if ((value instanceof Map)) { value = cloneMap((Map)value); } else if (!isBasicType(vClass)) { if ((value instanceof Cloneable)) { Method cloneMethod = vClass.getMethod("clone", NO_PARAMS_DEF); if (Modifier.isPublic(cloneMethod.getModifiers())) { value = cloneMethod.invoke(value, NO_PARAMS); } else { throw new CloneNotSupportedException("Cannot clone a " + value.getClass() + " object, clone() is not public"); } } else { throw new CloneNotSupportedException("Cannot clone a " + vClass.getName() + " object"); } } } return value; } private Object cloneArray(Object array) throws Exception { Class elementClass = array.getClass().getComponentType(); int length = Array.getLength(array); Object newArray = Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { Object element = doClone(Array.get(array, i)); Array.set(newArray, i, element); } return newArray; } private Object cloneCollection(Collection collection) throws Exception { Class mClass = collection.getClass(); Collection newColl = (Collection)mClass.newInstance(); Iterator i = collection.iterator(); while (i.hasNext()) { Object element = doClone(i.next()); newColl.add(element); } return newColl; } private Object cloneMap(Map map) throws Exception { Class mClass = map.getClass(); Map newMap = (Map)mClass.newInstance(); Iterator entries = map.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry)entries.next(); Object key = doClone(entry.getKey()); Object value = doClone(entry.getValue()); newMap.put(key, value); } return newMap; } private static final Set BASIC_TYPES = new HashSet(); private static final Map CONSTRUCTOR_BASIC_TYPES; static { BASIC_TYPES.add(Boolean.class); BASIC_TYPES.add(Byte.class); BASIC_TYPES.add(Character.class); BASIC_TYPES.add(Double.class); BASIC_TYPES.add(Float.class); BASIC_TYPES.add(Integer.class); BASIC_TYPES.add(Long.class); BASIC_TYPES.add(Short.class); BASIC_TYPES.add(String.class); CONSTRUCTOR_BASIC_TYPES = new HashMap(); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Boolean, new Class[] { Boolean.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Byte, new Class[] { Byte.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Character, new Class[] { Character.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Double, new Class[] { Double.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Float, new Class[] { Float.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Integer, new Class[] { Integer.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Long, new Class[] { Long.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$Short, new Class[] { Short.TYPE }); CONSTRUCTOR_BASIC_TYPES.put(class$java$lang$String, new Class[] { String.class }); } private boolean isBasicType(Class vClass) { return BASIC_TYPES.contains(vClass); } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.CloneableBean * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import com.sun.syndication.feed.CopyFrom; import java.beans.PropertyDescriptor; import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class CopyFromHelper { private static final Object[] NO_PARAMS = new Object[0]; private Class _beanInterfaceClass; private Map _baseInterfaceMap; private Map _baseImplMap; public CopyFromHelper(Class beanInterfaceClass, Map basePropInterfaceMap, Map basePropClassImplMap) { _beanInterfaceClass = beanInterfaceClass; _baseInterfaceMap = basePropInterfaceMap; _baseImplMap = basePropClassImplMap; } public void copy(Object target, Object source) { try { PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_beanInterfaceClass); if (pds != null) { for (int i = 0; i < pds.length; i++) { String propertyName = pds[i].getName(); Method pReadMethod = pds[i].getReadMethod(); Method pWriteMethod = pds[i].getWriteMethod(); if ((pReadMethod != null) && (pWriteMethod != null) && (pReadMethod.getDeclaringClass() != Object.class) && (pReadMethod.getParameterTypes().length == 0) && (_baseInterfaceMap.containsKey(propertyName))) { Object value = pReadMethod.invoke(source, NO_PARAMS); if (value != null) { Class baseInterface = (Class)_baseInterfaceMap.get(propertyName); value = doCopy(value, baseInterface); pWriteMethod.invoke(target, new Object[] { value }); } } } } } catch (Exception ex) { throw new RuntimeException("Could not do a copyFrom " + ex, ex); } } private CopyFrom createInstance(Class interfaceClass) throws Exception { if (_baseImplMap.get(interfaceClass) == null) { return null; } return (CopyFrom)((Class)_baseImplMap.get(interfaceClass)).newInstance(); } private Object doCopy(Object value, Class baseInterface) throws Exception { if (value != null) { Class vClass = value.getClass(); if (vClass.isArray()) { value = doCopyArray(value, baseInterface); } else if ((value instanceof Collection)) { value = doCopyCollection((Collection)value, baseInterface); } else if ((value instanceof Map)) { value = doCopyMap((Map)value, baseInterface); } else if (isBasicType(vClass)) { if ((value instanceof Date)) { value = ((Date)value).clone(); } } else if ((value instanceof CopyFrom)) { CopyFrom source = (CopyFrom)value; CopyFrom target = createInstance(source.getInterface()); target = target == null ? (CopyFrom)value.getClass().newInstance() : target; target.copyFrom(source); value = target; } else { throw new Exception("unsupported class for 'copyFrom' " + value.getClass()); } } return value; } private Object doCopyArray(Object array, Class baseInterface) throws Exception { Class elementClass = array.getClass().getComponentType(); int length = Array.getLength(array); Object newArray = Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { Object element = doCopy(Array.get(array, i), baseInterface); Array.set(newArray, i, element); } return newArray; } private Object doCopyCollection(Collection collection, Class baseInterface) throws Exception { Collection newColl = (collection instanceof Set) ? new HashSet() : new ArrayList(); Iterator i = collection.iterator(); while (i.hasNext()) { Object element = doCopy(i.next(), baseInterface); newColl.add(element); } return newColl; } private Object doCopyMap(Map map, Class baseInterface) throws Exception { Map newMap = new HashMap(); Iterator entries = map.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry)entries.next(); Object key = entry.getKey(); Object element = doCopy(entry.getValue(), baseInterface); newMap.put(key, element); } return newMap; } private static final Set BASIC_TYPES = new HashSet(); static { BASIC_TYPES.add(Boolean.class); BASIC_TYPES.add(Byte.class); BASIC_TYPES.add(Character.class); BASIC_TYPES.add(Double.class); BASIC_TYPES.add(Float.class); BASIC_TYPES.add(Integer.class); BASIC_TYPES.add(Long.class); BASIC_TYPES.add(Short.class); BASIC_TYPES.add(String.class); BASIC_TYPES.add(Date.class); } private boolean isBasicType(Class vClass) { return BASIC_TYPES.contains(vClass); } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.CopyFromHelper * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Array; import java.lang.reflect.Method; public class EqualsBean implements Serializable { private static final Object[] NO_PARAMS = new Object[0]; private Class _beanClass; private Object _obj; protected EqualsBean(Class beanClass) { _beanClass = beanClass; _obj = this; } public EqualsBean(Class beanClass, Object obj) { if (!beanClass.isInstance(obj)) { throw new IllegalArgumentException(obj.getClass() + " is not instance of " + beanClass); } _beanClass = beanClass; _obj = obj; } public boolean equals(Object obj) { return beanEquals(obj); } public boolean beanEquals(Object obj) { Object bean1 = _obj; Object bean2 = obj; boolean eq; boolean eq; if ((bean1 == null) && (bean2 == null)) { eq = true; } else { boolean eq; if ((bean1 == null) || (bean2 == null)) { eq = false; } else { boolean eq; if (!_beanClass.isInstance(bean2)) { eq = false; } else { eq = true; try { PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_beanClass); if (pds != null) { for (int i = 0; (eq) && (i < pds.length); i++) { Method pReadMethod = pds[i].getReadMethod(); if ((pReadMethod != null) && (pReadMethod.getDeclaringClass() != Object.class) && (pReadMethod.getParameterTypes().length == 0)) { Object value1 = pReadMethod.invoke(bean1, NO_PARAMS); Object value2 = pReadMethod.invoke(bean2, NO_PARAMS); eq = doEquals(value1, value2); } } } } catch (Exception ex) { throw new RuntimeException("Could not execute equals()", ex); } } } } return eq; } public int hashCode() { return beanHashCode(); } public int beanHashCode() { return _obj.toString().hashCode(); } private boolean doEquals(Object obj1, Object obj2) { boolean eq = obj1 == obj2; if ((!eq) && (obj1 != null) && (obj2 != null)) { Class classObj1 = obj1.getClass(); Class classObj2 = obj2.getClass(); if ((classObj1.isArray()) && (classObj2.isArray())) { eq = equalsArray(obj1, obj2); } else { eq = obj1.equals(obj2); } } return eq; } private boolean equalsArray(Object array1, Object array2) { int length1 = Array.getLength(array1); int length2 = Array.getLength(array2); boolean eq; if (length1 == length2) { boolean eq = true; for (int i = 0; (eq) && (i < length1); i++) { Object e1 = Array.get(array1, i); Object e2 = Array.get(array2, i); eq = doEquals(e1, e2); } } else { eq = false; } return eq; } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.EqualsBean * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.io.Serializable; import java.util.Set; public class ObjectBean implements Serializable, Cloneable { private EqualsBean _equalsBean; private ToStringBean _toStringBean; private CloneableBean _cloneableBean; public ObjectBean(Class beanClass, Object obj) { this(beanClass, obj, null); } public ObjectBean(Class beanClass, Object obj, Set ignoreProperties) { _equalsBean = new EqualsBean(beanClass, obj); _toStringBean = new ToStringBean(beanClass, obj); _cloneableBean = new CloneableBean(obj, ignoreProperties); } public Object clone() throws CloneNotSupportedException { return _cloneableBean.beanClone(); } public boolean equals(Object other) { return _equalsBean.beanEquals(other); } public int hashCode() { return _equalsBean.beanHashCode(); } public String toString() { return _toStringBean.toString(); } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.ObjectBean * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.util.Stack; class ToStringBean$1 extends ThreadLocal { public Object get() { Object o = super.get(); if (o == null) { o = new Stack(); set(o); } return o; } } /* Location: * Qualified Name: com.sun.syndication.feed.impl.ToStringBean.1 * Java Class Version: 1.4 (48.0) * JD-Core Version: 0.7.1 */ package com.sun.syndication.feed.impl; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.Stack; public class ToStringBean implements Serializable { private static final ThreadLocal PREFIX_TL = new ThreadLocal() { public Object get() { Object o = super.get(); if (o == null) { o = new Stack(); Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|