de.altimos.util.asset.ext.XmlDocument.java Source code

Java tutorial

Introduction

Here is the source code for de.altimos.util.asset.ext.XmlDocument.java

Source

/*
 * A Java Utility Library
 * 
 * Copyright (C) 2010-2012 Jan Graichen <jg@altimos.de>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * See the NOTICE file distributed along with this work for further
 * information.
 */
package de.altimos.util.asset.ext;

import org.jdom2.Document;

import de.altimos.util.asset.Asset;
import de.altimos.util.asset.AssetKey;

/**
 * A xml Document wrapper to use jdom lib with asset system.
 * 
 * @author Jan Graichen <jg@altimos.de>
 * @version $Id$
 */
public class XmlDocument extends Document implements Asset {

    private static final long serialVersionUID = -1888763530630618723L;

    @SuppressWarnings("rawtypes")
    private AssetKey key;

    @SuppressWarnings("rawtypes")
    public XmlDocument(AssetKey key) {
        this(key, null);
    }

    @SuppressWarnings("rawtypes")
    public XmlDocument(AssetKey key, Document doc) {
        super();
        if (doc != null) {
            setDocType(doc.getDocType());
            setBaseURI(doc.getBaseURI());
            setContent(doc.getRootElement().detach());
        }
        this.key = key;
    }

    @Override
    @SuppressWarnings("rawtypes")
    public AssetKey getAssetKey() {
        return key;
    }

}