001/*
002 * (C) Copyright 2006-2007 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 *     Nuxeo - initial API and implementation
018 *
019 * $Id: QNameResourceImpl.java 20796 2007-06-19 09:52:03Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.relations.api.impl;
023
024import org.nuxeo.ecm.platform.relations.api.NodeType;
025import org.nuxeo.ecm.platform.relations.api.QNameResource;
026
027/**
028 * Prefixed resource.
029 * <p>
030 * New prefixed resources can be declared through extension points.
031 *
032 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
033 */
034public class QNameResourceImpl extends ResourceImpl implements QNameResource {
035
036    private static final long serialVersionUID = 1L;
037
038    protected String namespace = "";
039
040    protected String localName;
041
042    public QNameResourceImpl(String namespace, String localName) {
043        super(namespace + localName);
044        this.namespace = namespace;
045        this.localName = localName;
046    }
047
048    @Override
049    public NodeType getNodeType() {
050        return NodeType.QNAMERESOURCE;
051    }
052
053    @Override
054    public boolean isQNameResource() {
055        return true;
056    }
057
058    @Override
059    public String toString() {
060        return String.format("%s('{%s}%s')", getClass().getSimpleName(), namespace, localName);
061    }
062
063    public String getNamespace() {
064        return namespace;
065    }
066
067    public String getLocalName() {
068        return localName;
069    }
070
071    public void setLocalName(String localName) {
072        this.localName = localName;
073    }
074
075}