001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.runtime.services.resource; 020 021import java.io.File; 022import java.net.URI; 023import java.net.URISyntaxException; 024import java.net.URL; 025 026import org.nuxeo.common.xmap.Resource; 027import org.nuxeo.common.xmap.annotation.XNode; 028import org.nuxeo.common.xmap.annotation.XObject; 029 030/** 031 * A pointer to a template located in the contributor bundle. 032 * 033 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 034 */ 035@XObject("resource") 036public class ResourceDescriptor { 037 038 @XNode("@name") 039 protected String name; 040 041 @XNode 042 protected Resource resource; 043 044 public ResourceDescriptor() { 045 046 } 047 048 public ResourceDescriptor(String name, Resource resource) { 049 this.name = name; 050 this.resource = resource; 051 } 052 053 public Resource getResource() { 054 return resource; 055 } 056 057 public String getName() { 058 return name; 059 } 060 061 public void setName(String name) { 062 this.name = name; 063 } 064 065 public void setResource(Resource resource) { 066 this.resource = resource; 067 } 068 069 public URL getUrl() { 070 return resource.toURL(); 071 } 072 073 public URI getUri() throws URISyntaxException { 074 return resource.toURI(); 075 } 076 077 public File getFile() throws URISyntaxException { 078 return resource.toFile(); 079 } 080 081 @Override 082 public String toString() { 083 return name + "@" + resource.toURL(); 084 } 085 086}