本文整理了Java中org.osgi.framework.Version.valueOf()
方法的一些代码示例,展示了Version.valueOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.valueOf()
方法的具体详情如下:
包路径:org.osgi.framework.Version
类名称:Version
方法名:valueOf
[英]Returns a Version object holding the version identifier in the specified String.
See #Version(String) for the format of the version string.
This method performs a similar function as #parseVersion(String)but has the static factory valueOf(String) method signature.
[中]返回在指定字符串中包含版本标识符的版本对象。
有关版本字符串的格式,请参见#版本(字符串)。
此方法执行与#parseVersion(String)类似的功能,但具有静态工厂值of(String)方法签名。
代码示例来源:origin: org.osgi/org.osgi.core
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: org.osgi/org.osgi.core
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: apache/felix
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: org.eclipse/osgi
/**
* Parses a version identifier from the specified string.
*
* <p>
* See {@link #Version(String)} for the format of the version string.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
* @return A {@code Version} object representing the version identifier. If
* {@code version} is {@code null} or the empty string then
* {@link #emptyVersion} will be returned.
* @throws IllegalArgumentException If {@code version} is improperly
* formatted.
*/
public static Version parseVersion(String version) {
if (version == null) {
return emptyVersion;
}
return valueOf(version);
}
代码示例来源:origin: apache/felix
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"invalid range \"" + range + "\": " + e.getMessage(), e);
}
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"invalid range \"" + range + "\": " + e.getMessage(), e);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"invalid range \"" + range + "\": " + e.getMessage(), e);
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: org.eclipse/osgi
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
/**
* Parse version component into a Version.
*
* @param version version component string
* @param range Complete range string for exception message, if any
* @return Version
*/
private static Version parseVersion(String version, String range) {
try {
return Version.valueOf(version);
} catch (IllegalArgumentException e) {
IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage());
iae.initCause(e);
throw iae;
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testGetPrefixWithWhitelistedBundle() throws Exception {
final Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getSymbolicName()).thenReturn("org.apache.brooklyn.my-bundle");
Mockito.when(bundle.getVersion()).thenReturn(Version.valueOf(BrooklynVersion.getOsgiVersion()));
Function<Class<?>, Optional<Bundle>> bundleRetriever = new Function<Class<?>, Optional<Bundle>>() {
@Override public Optional<Bundle> apply(Class<?> input) {
return Optional.of(bundle);
}
};
OsgiClassPrefixer prefixer = new OsgiClassPrefixer(bundleRetriever);
assertPresent(prefixer.getPrefix(String.class), "org.apache.brooklyn.my-bundle:");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testGetPrefixWithBundle() throws Exception {
final Class<?> classInBundle = String.class;
final Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getSymbolicName()).thenReturn("my.symbolic.name");
Mockito.when(bundle.getVersion()).thenReturn(Version.valueOf("1.2.3"));
Function<Class<?>, Optional<Bundle>> bundleRetriever = new Function<Class<?>, Optional<Bundle>>() {
@Override public Optional<Bundle> apply(Class<?> input) {
return (classInBundle.equals(input)) ? Optional.of(bundle) : Optional.<Bundle>absent();
}
};
OsgiClassPrefixer prefixer = new OsgiClassPrefixer(bundleRetriever);
assertAbsent(prefixer.getPrefix(Number.class));
assertPresent(prefixer.getPrefix(String.class), "my.symbolic.name:");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testStringPrefix() throws Exception {
Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getSymbolicName()).thenReturn("my.symbolic.name");
Mockito.when(bundle.getVersion()).thenReturn(Version.valueOf("1.2.3"));
OsgiClassPrefixer prefixer = new OsgiClassPrefixer();
assertAbsent(prefixer.stripMatchingPrefix(bundle, "my.package.MyClass"));
assertAbsent(prefixer.stripMatchingPrefix(bundle, "different.symbolic.name:my.package.MyClass"));
assertAbsent(prefixer.stripMatchingPrefix(bundle, "different.symbolic.name:1.2.3:my.package.MyClass"));
assertPresent(prefixer.stripMatchingPrefix(bundle, "my.symbolic.name:my.package.MyClass"), "my.package.MyClass");
assertPresent(prefixer.stripMatchingPrefix(bundle, "my.symbolic.name:1.2.3:my.package.MyClass"), "my.package.MyClass");
// TODO Will match any version - is that good enough?
// Is it the right thing to do, to make upgrades simpler?!
assertPresent(prefixer.stripMatchingPrefix(bundle, "my.symbolic.name:1.0.0:my.package.MyClass"), "my.package.MyClass");
}
内容来源于网络,如有侵权,请联系作者删除!