001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.runtime.services.resource; 013 014import java.io.File; 015import java.net.URI; 016import java.net.URISyntaxException; 017import java.net.URL; 018 019import org.nuxeo.common.xmap.Resource; 020import org.nuxeo.common.xmap.annotation.XNode; 021import org.nuxeo.common.xmap.annotation.XObject; 022 023/** 024 * A pointer to a template located in the contributor bundle. 025 * 026 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 027 */ 028@XObject("resource") 029public class ResourceDescriptor { 030 031 @XNode("@name") 032 protected String name; 033 034 @XNode 035 protected Resource resource; 036 037 public ResourceDescriptor() { 038 039 } 040 041 public ResourceDescriptor(String name, Resource resource) { 042 this.name = name; 043 this.resource = resource; 044 } 045 046 public Resource getResource() { 047 return resource; 048 } 049 050 public String getName() { 051 return name; 052 } 053 054 public void setName(String name) { 055 this.name = name; 056 } 057 058 public void setResource(Resource resource) { 059 this.resource = resource; 060 } 061 062 public URL getUrl() { 063 return resource.toURL(); 064 } 065 066 public URI getUri() throws URISyntaxException { 067 return resource.toURI(); 068 } 069 070 public File getFile() throws URISyntaxException { 071 return resource.toFile(); 072 } 073 074 @Override 075 public String toString() { 076 return name + "@" + resource.toURL(); 077 } 078 079}