Here you can find the source of parseVersionNamespace(String versionNamespace)
Parameter | Description |
---|---|
versionNamespace | string containing the namespace string indicating the version |
public static String[] parseVersionNamespace(String versionNamespace)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w w w . ja v a 2 s. c o m * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static final String PREFIX = "http://www.ibm.com/com.ibm.datatools.core/model/"; public static final String DATAMODEL_PREFIX = "http://www.ibm.com/com.ibm.datatools.core/model/data/"; public static final Pattern MODEL_URI_PATTERN = Pattern .compile(DATAMODEL_PREFIX + "(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)"); public static final Pattern OLD_MODEL_URI_PATTERN = Pattern .compile(PREFIX + "(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)"); /** * @param versionNamespace * string containing the namespace string indicating the version * @return string array containing the namespace prefix, major, minor, * service and modifier components; or null if the string is not a * valid version namespace */ public static String[] parseVersionNamespace(String versionNamespace) { Matcher matcher = MODEL_URI_PATTERN.matcher(versionNamespace); Matcher oldMatcher = OLD_MODEL_URI_PATTERN.matcher(versionNamespace); if (matcher.matches()) { return new String[] { DATAMODEL_PREFIX, matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(4) }; } else if (oldMatcher.matches()) { return new String[] { PREFIX, oldMatcher.group(1), oldMatcher.group(2), oldMatcher.group(3), oldMatcher.group(4) }; } else { return null; } } }