Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    final static public String TOPO_ID_PREFIX = "urn:ogf:network";
    final static public String[] TOPO_ID_PARTS = { "domain", "node", "port", "link" };
    final static public String TOPO_ID_SEPARATOR = ":";
    final static public String TOPO_ID_LABEL_SEPARATOR = "=";

    /**
     * Normalizes a URN by trimming whitespace, converting to lowercase, removing the prefix, 
     * and all labels such as <i>partType=</i>.
     * 
     * @param urn the URN to normalize
     * @return the normalized URN
     */
    static public String normalizeURN(String urn) {
        urn = urn.trim();
        urn = urn.toLowerCase();
        urn = urn.replaceAll(TOPO_ID_PREFIX + TOPO_ID_SEPARATOR, "");
        for (String part : TOPO_ID_PARTS) {
            urn = urn.replaceAll(part + TOPO_ID_LABEL_SEPARATOR, "");
        }

        return urn;
    }
}