Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2010 Ansgar Gerlicher
 * 
 * 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.
 * 
 * Stuttgart, Hochschule der Medien: http://www.mi.hdm-stuttgart.de/mmb/
 * Collaborative Editing Framework or XML:
 * http://sourceforge.net/projects/cefx/
 * 
 * Dresden, University of Technology, Faculty of Computer Science
 * Computer Networks Group: http://www.rn.inf.tu-dresden.de
 * mobilis project: http://mobilisplatform.sourceforge.net
 ******************************************************************************/

import org.w3c.dom.Attr;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static final String CEFX_NAMESPACE = "http://www.hdm-stuttgart.de/~gerlicher/cefx";
    public static final String CEFXUID = "cefx:uid";

    /**
     * Allows to retrieve the UUID of the node.
     * @param node node to be modified.
     * @return the UUID of the node.
     */
    public static String getNodeId(Node node) {
        String nodeId = null;
        NamedNodeMap nnm = node.getAttributes();
        if (nnm != null) {
            Attr a = (Attr) nnm.getNamedItemNS(CEFX_NAMESPACE, CEFXUID);
            if (a == null) {
                String name = CEFXUID;
                a = (Attr) nnm.getNamedItem(name);
            }
            if (a != null) {
                nodeId = a.getNodeValue();
            }
        }
        return nodeId;
    }
}