001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: QNameResourceImpl.java 20796 2007-06-19 09:52:03Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.relations.api.impl;
021
022import org.nuxeo.ecm.platform.relations.api.NodeType;
023import org.nuxeo.ecm.platform.relations.api.QNameResource;
024
025/**
026 * Prefixed resource.
027 * <p>
028 * New prefixed resources can be declared through extension points.
029 *
030 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
031 */
032public class QNameResourceImpl extends ResourceImpl implements QNameResource {
033
034    private static final long serialVersionUID = 1L;
035
036    protected String namespace = "";
037
038    protected String localName;
039
040    public QNameResourceImpl(String namespace, String localName) {
041        super(namespace + localName);
042        this.namespace = namespace;
043        this.localName = localName;
044    }
045
046    @Override
047    public NodeType getNodeType() {
048        return NodeType.QNAMERESOURCE;
049    }
050
051    @Override
052    public boolean isQNameResource() {
053        return true;
054    }
055
056    @Override
057    public String toString() {
058        return String.format("%s('{%s}%s')", getClass().getSimpleName(), namespace, localName);
059    }
060
061    public String getNamespace() {
062        return namespace;
063    }
064
065    public String getLocalName() {
066        return localName;
067    }
068
069    public void setLocalName(String localName) {
070        this.localName = localName;
071    }
072
073}