📄 didlobject.java
字号:
this(null); } public RADIO_STATION_ID(String value) { super(value, "radioStationID"); } } static public class RADIO_BAND extends Property<String> implements NAMESPACE { public RADIO_BAND() { this(null); } public RADIO_BAND(String value) { super(value, "radioBand"); } } static public class CHANNEL_NR extends Property<Integer> implements NAMESPACE { public CHANNEL_NR() { this(null); } public CHANNEL_NR(Integer value) { super(value, "channelNr"); } } static public class CHANNEL_NAME extends Property<String> implements NAMESPACE { public CHANNEL_NAME() { this(null); } public CHANNEL_NAME(String value) { super(value, "channelName"); } } static public class SCHEDULED_START_TIME extends Property<String> implements NAMESPACE { public SCHEDULED_START_TIME() { this(null); } public SCHEDULED_START_TIME(String value) { super(value, "scheduledStartTime"); } } static public class SCHEDULED_END_TIME extends Property<String> implements NAMESPACE { public SCHEDULED_END_TIME() { this(null); } public SCHEDULED_END_TIME(String value) { super(value, "scheduledEndTime"); } } static public class DVD_REGION_CODE extends Property<Integer> implements NAMESPACE { public DVD_REGION_CODE() { this(null); } public DVD_REGION_CODE(Integer value) { super(value, "DVDRegionCode"); } } static public class ORIGINAL_TRACK_NUMBER extends Property<Integer> implements NAMESPACE { public ORIGINAL_TRACK_NUMBER() { this(null); } public ORIGINAL_TRACK_NUMBER(Integer value) { super(value, "originalTrackNumber"); } } static public class USER_ANNOTATION extends Property<String> implements NAMESPACE { public USER_ANNOTATION() { this(null); } public USER_ANNOTATION(String value) { super(value, "userAnnotation"); } } } static public abstract class DLNA { public interface NAMESPACE extends Property.NAMESPACE { public static final String URI = "urn:schemas-dlna-org:metadata-1-0/"; } static public class PROFILE_ID extends Property<DIDLAttribute> implements NAMESPACE { public PROFILE_ID() { this(null); } public PROFILE_ID(DIDLAttribute value) { super(value, "profileID"); } } } } public static class Class { protected String value; protected String friendlyName; protected boolean includeDerived; public Class() { } public Class(String value) { this.value = value; } public Class(String value, String friendlyName) { this.value = value; this.friendlyName = friendlyName; } public Class(String value, String friendlyName, boolean includeDerived) { this.value = value; this.friendlyName = friendlyName; this.includeDerived = includeDerived; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String getFriendlyName() { return friendlyName; } public void setFriendlyName(String friendlyName) { this.friendlyName = friendlyName; } public boolean isIncludeDerived() { return includeDerived; } public void setIncludeDerived(boolean includeDerived) { this.includeDerived = includeDerived; } public boolean equals(DIDLObject instance) { return getValue().equals(instance.getClazz().getValue()); } } protected String id; protected String parentID; protected String title; // DC protected String creator; // DC protected boolean restricted = true; // Let's just assume read-only is default protected WriteStatus writeStatus; // UPNP protected Class clazz; // UPNP protected List<Res> resources = new ArrayList(); protected List<Property> properties = new ArrayList(); protected List<DescMeta> descMetadata = new ArrayList(); protected DIDLObject() { } protected DIDLObject(DIDLObject other) { this(other.getId(), other.getParentID(), other.getTitle(), other.getCreator(), other.isRestricted(), other.getWriteStatus(), other.getClazz(), other.getResources(), other.getProperties(), other.getDescMetadata() ); } protected DIDLObject(String id, String parentID, String title, String creator, boolean restricted, WriteStatus writeStatus, Class clazz, List<Res> resources, List<Property> properties, List<DescMeta> descMetadata) { this.id = id; this.parentID = parentID; this.title = title; this.creator = creator; this.restricted = restricted; this.writeStatus = writeStatus; this.clazz = clazz; this.resources = resources; this.properties = properties; this.descMetadata = descMetadata; } public String getId() { return id; } public DIDLObject setId(String id) { this.id = id; return this; } public String getParentID() { return parentID; } public DIDLObject setParentID(String parentID) { this.parentID = parentID; return this; } public String getTitle() { return title; } public DIDLObject setTitle(String title) { this.title = title; return this; } public String getCreator() { return creator; } public DIDLObject setCreator(String creator) { this.creator = creator; return this; } public boolean isRestricted() { return restricted; } public DIDLObject setRestricted(boolean restricted) { this.restricted = restricted; return this; } public WriteStatus getWriteStatus() { return writeStatus; } public DIDLObject setWriteStatus(WriteStatus writeStatus) { this.writeStatus = writeStatus; return this; } public Res getFirstResource() { return getResources().size() > 0 ? getResources().get(0) : null; } public List<Res> getResources() { return resources; } public DIDLObject setResources(List<Res> resources) { this.resources = resources; return this; } public DIDLObject addResource(Res resource) { getResources().add(resource); return this; } public Class getClazz() { return clazz; } public DIDLObject setClazz(Class clazz) { this.clazz = clazz; return this; } public List<Property> getProperties() { return properties; } public DIDLObject setProperties(List<Property> properties) { this.properties = properties; return this; } public DIDLObject addProperty(Property property) { if (property == null) return this; getProperties().add(property); return this; } public DIDLObject replaceFirstProperty(Property property) { if (property == null) return this; Iterator<Property> it = getProperties().iterator(); while (it.hasNext()) { Property p = it.next(); if (p.getClass().isAssignableFrom(property.getClass())) it.remove(); } addProperty(property); return this; } public DIDLObject replaceProperties(java.lang.Class<? extends Property> propertyClass, Property[] properties) { if (properties.length == 0) return this; removeProperties(propertyClass); return addProperties(properties); } public DIDLObject addProperties(Property[] properties) { if (properties == null) return this; for (Property property : properties) { addProperty(property); } return this; } public DIDLObject removeProperties(java.lang.Class<? extends Property> propertyClass) { Iterator<Property> it = getProperties().iterator(); while (it.hasNext()) { Property p = it.next(); if (p.getClass().isAssignableFrom(propertyClass)) it.remove(); } return this; } public boolean hasProperty(java.lang.Class<? extends Property> propertyClass) { for (Property property : getProperties()) { if (property.getClass().isAssignableFrom(propertyClass)) return true; } return false; } public <V> Property<V> getFirstProperty(java.lang.Class<? extends Property<V>> propertyClass) { for (Property property : getProperties()) { if (property.getClass().isAssignableFrom(propertyClass)) return property; } return null; } public <V> Property<V> getLastProperty(java.lang.Class<? extends Property<V>> propertyClass) { Property found = null; for (Property property : getProperties()) { if (property.getClass().isAssignableFrom(propertyClass)) found = property; } return found; } public <V> Property<V>[] getProperties(java.lang.Class<? extends Property<V>> propertyClass) { List<Property<V>> list = new ArrayList(); for (Property property : getProperties()) { if (property.getClass().isAssignableFrom(propertyClass)) list.add(property); } return list.toArray(new Property[list.size()]); } public <V> Property<V>[] getPropertiesByNamespace(java.lang.Class<? extends Property.NAMESPACE> namespace) { List<Property<V>> list = new ArrayList(); for (Property property : getProperties()) { if (namespace.isAssignableFrom(property.getClass())) list.add(property); } return list.toArray(new Property[list.size()]); } public <V> V getFirstPropertyValue(java.lang.Class<? extends Property<V>> propertyClass) { Property<V> prop = getFirstProperty(propertyClass); return prop == null ? null : prop.getValue(); } public <V> List<V> getPropertyValues(java.lang.Class<? extends Property<V>> propertyClass) { List<V> list = new ArrayList(); for (Property property : getProperties(propertyClass)) { list.add((V) property.getValue()); } return list; } public List<DescMeta> getDescMetadata() { return descMetadata; } public void setDescMetadata(List<DescMeta> descMetadata) { this.descMetadata = descMetadata; } public DIDLObject addDescMetadata(DescMeta descMetadata) { getDescMetadata().add(descMetadata); return this; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DIDLObject that = (DIDLObject) o; if (!id.equals(that.id)) return false; return true; } @Override public int hashCode() { return id.hashCode(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -