Here you can find the source of getLocalName(URI uri)
Parameter | Description |
---|---|
uri | a parameter |
public static String getLocalName(URI uri)
//package com.java2s; //License from project: GNU General Public License import java.net.URI; public class Main { /**//w w w . j av a 2 s .c o m * Return the local name of a URI. This function is not equiavlent to * URI.getFragment() because it tries to handle handle slashy URI's * such as the ones found in Dublin Core. It is equiavalent to * getLocalName(uri.toString()). * * @param uri * @return */ public static String getLocalName(URI uri) { return getLocalName(uri.toString()); } /** * Return the local name of a URI string. This naive implementation splits * the URI from the position of a '#' character or the last occurunce of * '/' character. If neither of these characters are found, the parameter * itself is returned. * * @param uri * @return */ public static String getLocalName(String uri) { int index = splitPos(uri); if (index == -1) return uri; return uri.substring(index + 1); } private static int splitPos(String uri) { int pos = uri.indexOf("#"); if (pos == -1) pos = uri.lastIndexOf("/"); return pos; } }