Java Code Examples for org.fourthline.cling.support.model.DIDLObject#Class

The following examples show how to use org.fourthline.cling.support.model.DIDLObject#Class . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent,
		DIDLObject.Class clazz, String element, boolean appendDerivation) {
	Element classElement = appendNewElementIfNotNull(descriptor, parent,
			element, clazz.getValue(),
			DIDLObject.Property.UPNP.NAMESPACE.URI);
	if (clazz.getFriendlyName() != null
			&& clazz.getFriendlyName().length() > 0)
		classElement.setAttribute("name", clazz.getFriendlyName());
	if (appendDerivation)
		classElement.setAttribute("includeDerived",
				Boolean.toString(clazz.isIncludeDerived()));
}
 
Example 2
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) {
    Element classElement = appendNewElementIfNotNull(
            descriptor,
            parent,
            element,
            clazz.getValue(),
            DIDLObject.Property.UPNP.NAMESPACE.URI
    );
    if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0)
        classElement.setAttribute("name", clazz.getFriendlyName());
    if (appendDerivation)
        classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived()));
}
 
Example 3
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) {
    Element classElement = appendNewElementIfNotNull(
            descriptor,
            parent,
            element,
            clazz.getValue(),
            DIDLObject.Property.UPNP.NAMESPACE.URI
    );
    if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0)
        classElement.setAttribute("name", clazz.getFriendlyName());
    if (appendDerivation)
        classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived()));
}
 
Example 4
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateContainer(Container container, Document descriptor, Element parent, boolean nestedItems) {

        if (container.getClazz() == null) {
            throw new RuntimeException("Missing 'upnp:class' element for container: " + container.getId());
        }

        Element containerElement = appendNewElement(descriptor, parent, "container");

        if (container.getId() == null)
            throw new NullPointerException("Missing id on container: " + container);
        containerElement.setAttribute("id", container.getId());

        if (container.getParentID() == null)
            throw new NullPointerException("Missing parent id on container: " + container);
        containerElement.setAttribute("parentID", container.getParentID());

        if (container.getChildCount() != null) {
            containerElement.setAttribute("childCount", Integer.toString(container.getChildCount()));
        }

        containerElement.setAttribute("restricted", booleanToInt(container.isRestricted()));
        containerElement.setAttribute("searchable", booleanToInt(container.isSearchable()));

        String title = container.getTitle();
           if (title == null) {
           	log.warning("Missing 'dc:title' element for container: " + container.getId());
           	title = UNKNOWN_TITLE;
           }

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:title",
                title,
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:creator",
                container.getCreator(),
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "upnp:writeStatus",
                container.getWriteStatus(),
                DIDLObject.Property.UPNP.NAMESPACE.URI
        );

        appendClass(descriptor, containerElement, container.getClazz(), "upnp:class", false);

        for (DIDLObject.Class searchClass : container.getSearchClasses()) {
            appendClass(descriptor, containerElement, searchClass, "upnp:searchClass", true);
        }

        for (DIDLObject.Class createClass : container.getCreateClasses()) {
            appendClass(descriptor, containerElement, createClass, "upnp:createClass", true);
        }

        appendProperties(descriptor, containerElement, container, "upnp", DIDLObject.Property.UPNP.NAMESPACE.class, DIDLObject.Property.UPNP.NAMESPACE.URI);
        appendProperties(descriptor, containerElement, container, "dc", DIDLObject.Property.DC.NAMESPACE.class, DIDLObject.Property.DC.NAMESPACE.URI);

        if (nestedItems) {
            for (Item item : container.getItems()) {
                if (item == null) continue;
                generateItem(item, descriptor, containerElement);
            }
        }

        for (Res resource : container.getResources()) {
            if (resource == null) continue;
            generateResource(resource, descriptor, containerElement);
        }

        for (DescMeta descMeta : container.getDescMetadata()) {
            if (descMeta == null) continue;
            generateDescMetadata(descMeta, descriptor, containerElement);
        }
    }
 
Example 5
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, String parentID, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parentID, title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example 6
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example 7
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, false, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 8
Source File: Item.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}
 
Example 9
Source File: Item.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 10
Source File: Item.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Item(String id, Container parent, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parent.getId(), title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}
 
Example 11
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateContainer(Container container, Document descriptor,
		Element parent, boolean nestedItems) {

	if (container.getClazz() == null) {
		throw new RuntimeException(
				"Missing 'upnp:class' element for container: "
						+ container.getId());
	}

	Element containerElement = appendNewElement(descriptor, parent,
			"container");

	if (container.getId() == null)
		throw new NullPointerException("Missing id on container: "
				+ container);
	containerElement.setAttribute("id", container.getId());

	if (container.getParentID() == null)
		throw new NullPointerException("Missing parent id on container: "
				+ container);
	containerElement.setAttribute("parentID", container.getParentID());

	if (container.getChildCount() != null) {
		containerElement.setAttribute("childCount",
				Integer.toString(container.getChildCount()));
	}

	containerElement.setAttribute("restricted",
			booleanToInt(container.isRestricted()));
	containerElement.setAttribute("searchable",
			booleanToInt(container.isSearchable()));

	String title = container.getTitle();
	if (title == null) {
		title = UNKNOWN_TITLE;
	}

	appendNewElementIfNotNull(descriptor, containerElement, "dc:title",
			title, DIDLObject.Property.DC.NAMESPACE.URI);

	appendNewElementIfNotNull(descriptor, containerElement, "dc:creator",
			container.getCreator(), DIDLObject.Property.DC.NAMESPACE.URI);

	appendNewElementIfNotNull(descriptor, containerElement,
			"upnp:writeStatus", container.getWriteStatus(),
			DIDLObject.Property.UPNP.NAMESPACE.URI);

	appendClass(descriptor, containerElement, container.getClazz(),
			"upnp:class", false);

	for (DIDLObject.Class searchClass : container.getSearchClasses()) {
		appendClass(descriptor, containerElement, searchClass,
				"upnp:searchClass", true);
	}

	for (DIDLObject.Class createClass : container.getCreateClasses()) {
		appendClass(descriptor, containerElement, createClass,
				"upnp:createClass", true);
	}

	appendProperties(descriptor, containerElement, container, "upnp",
			DIDLObject.Property.UPNP.NAMESPACE.class,
			DIDLObject.Property.UPNP.NAMESPACE.URI);
	appendProperties(descriptor, containerElement, container, "dc",
			DIDLObject.Property.DC.NAMESPACE.class,
			DIDLObject.Property.DC.NAMESPACE.URI);

	if (nestedItems) {
		for (Item item : container.getItems()) {
			if (item == null)
				continue;
			generateItem(item, descriptor, containerElement);
		}
	}

	for (Res resource : container.getResources()) {
		if (resource == null)
			continue;
		generateResource(resource, descriptor, containerElement);
	}

	for (DescMeta descMeta : container.getDescMetadata()) {
		if (descMeta == null)
			continue;
		generateDescMetadata(descMeta, descriptor, containerElement);
	}
}
 
Example 12
Source File: GenerateContentTask.java    From HPlayer with Apache License 2.0 4 votes vote down vote up
/**
     * 添加图片
     */
    private void addImageContent(Context context, ContentNode rootNode) {

        Container imageContainer = new Container(ContentTree.IMAGE_ID,
                ContentTree.ROOT_ID, "Images", "HPlayer MediaServer",
                new DIDLObject.Class("object.container"), 0);
        imageContainer.setRestricted(true);
        imageContainer.setWriteStatus(WriteStatus.NOT_WRITABLE);

        rootNode.getContainer().addContainer(imageContainer);
        rootNode.getContainer().setChildCount(
                rootNode.getContainer().getChildCount() + 1);
        ContentTree.addNode(ContentTree.IMAGE_ID, new ContentNode(
                ContentTree.IMAGE_ID, imageContainer));

        Cursor cursor = context.getContentResolver()
                .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        null, null, null, null);
        if (cursor == null) {
            return;
        }

        while (cursor.moveToNext()) {
            String id = ContentTree.IMAGE_PREFIX
                    + cursor.getInt(cursor.getColumnIndex(MediaStore.Images.Media._ID));
            String title = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.TITLE));
            String creator = "unkown";
            String filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
            String mimeType = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.MIME_TYPE));
            long size = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.SIZE));

            Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
                    mimeType.substring(mimeType.indexOf('/') + 1)), size,
                    "http://" + address + "/" + id);

            ImageItem imageItem = new ImageItem(id, ContentTree.IMAGE_ID, title, creator, res);
            imageContainer.addItem(imageItem);
            imageContainer.setChildCount(imageContainer.getChildCount() + 1);
            ContentTree.addNode(id, new ContentNode(id, imageItem, filePath));

//            Log.d(TAG, "added image item " + title + "from " + filePath);
        }

        cursor.close();
    }
 
Example 13
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, Container parent, String title, String creator, DIDLObject.Class clazz) {
    this(id, parent.getId(), title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 14
Source File: Container.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Container(String id, String parentID, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parentID, title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example 15
Source File: Container.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example 16
Source File: Container.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Container(String id, String parentID, String title, String creator, DIDLObject.Class clazz, Integer childCount) {
    this(id, parentID, title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, false, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 17
Source File: Container.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, false, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 18
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}
 
Example 19
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example 20
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, Container parent, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parent.getId(), title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}