本文整理了Java中hudson.Util.intern()
方法的一些代码示例,展示了Util.intern()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.intern()
方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:intern
[英]Null-safe String intern method.
[中]空安全字符串实习生方法。
代码示例来源:origin: jenkinsci/jenkins
/** Returns the input strings, but with all values interned. */
public static String[] internInPlace(String[] input) {
if (input == null) {
return null;
} else if (input.length == 0) {
return EMPTY_STRING_ARRAY;
}
for (int i=0; i<input.length; i++) {
input[i] = Util.intern(input[i]);
}
return input;
}
代码示例来源:origin: jenkinsci/jenkins
public Dependency(String s) {
int idx = s.indexOf(':');
if(idx==-1)
throw new IllegalArgumentException("Illegal dependency specifier "+s);
this.shortName = Util.intern(s.substring(0,idx));
String version = Util.intern(s.substring(idx+1));
boolean isOptional = false;
String[] osgiProperties = version.split("[;]");
for (int i = 1; i < osgiProperties.length; i++) {
String osgiProperty = osgiProperties[i].trim();
if (osgiProperty.equalsIgnoreCase("resolution:=optional")) {
isOptional = true;
}
}
this.optional = isOptional;
if (isOptional) {
this.version = osgiProperties[0];
} else {
this.version = version;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @param archive
* A .jpi archive file jar file, or a .jpl linked plugin.
* @param manifest
* The manifest for the plugin
* @param baseResourceURL
* A URL pointing to the resources for this plugin
* @param classLoader
* a classloader that loads classes from this plugin and its dependencies
* @param disableFile
* if this file exists on startup, the plugin will not be activated
* @param dependencies a list of mandatory dependencies
* @param optionalDependencies a list of optional dependencies
*/
public PluginWrapper(PluginManager parent, File archive, Manifest manifest, URL baseResourceURL,
ClassLoader classLoader, File disableFile,
List<Dependency> dependencies, List<Dependency> optionalDependencies) {
this.parent = parent;
this.manifest = manifest;
this.shortName = Util.intern(computeShortName(manifest, archive.getName()));
this.baseResourceURL = baseResourceURL;
this.classLoader = classLoader;
this.disableFile = disableFile;
this.active = !disableFile.exists();
this.dependencies = dependencies;
this.optionalDependencies = optionalDependencies;
this.archive = archive;
}
代码示例来源:origin: jenkinsci/jenkins
public WarningVersionRange(JSONObject o) {
this.name = Util.fixEmpty(o.optString("name"));
this.firstVersion = Util.intern(Util.fixEmpty(o.optString("firstVersion")));
this.lastVersion = Util.intern(Util.fixEmpty(o.optString("lastVersion")));
Pattern p;
try {
p = Pattern.compile(o.getString("pattern"));
} catch (PatternSyntaxException ex) {
LOGGER.log(Level.WARNING, "Failed to compile pattern '" + o.getString("pattern") + "', using '.*' instead", ex);
p = Pattern.compile(".*");
}
this.pattern = p;
}
代码示例来源:origin: jenkinsci/jenkins
Entry(String sourceId, JSONObject o, String baseURL) {
this.sourceId = sourceId;
this.name = Util.intern(o.getString("name"));
this.version = Util.intern(o.getString("version"));
// Trim this to prevent issues when the other end used Base64.encodeBase64String that added newlines
// to the end in old commons-codec. Not the case on updates.jenkins-ci.org, but let's be safe.
this.sha1 = Util.fixEmptyAndTrim(o.optString("sha1"));
this.sha256 = Util.fixEmptyAndTrim(o.optString("sha256"));
this.sha512 = Util.fixEmptyAndTrim(o.optString("sha512"));
String url = o.getString("url");
if (!URI.create(url).isAbsolute()) {
if (baseURL == null) {
throw new IllegalArgumentException("Cannot resolve " + url + " without a base URL");
}
url = URI.create(baseURL).resolve(url).toString();
}
this.url = url;
}
代码示例来源:origin: jenkinsci/jenkins
@DataBoundConstructor
public Plugin(String sourceId, JSONObject o) {
super(sourceId, o, UpdateSite.this.url);
this.wiki = get(o,"wiki");
this.title = get(o,"title");
this.excerpt = get(o,"excerpt");
this.compatibleSinceVersion = Util.intern(get(o,"compatibleSinceVersion"));
this.minimumJavaVersion = Util.intern(get(o, "minimumJavaVersion"));
this.requiredCore = Util.intern(get(o,"requiredCore"));
this.categories = o.has("labels") ? internInPlace((String[])o.getJSONArray("labels").toArray(EMPTY_STRING_ARRAY)) : null;
JSONArray ja = o.getJSONArray("dependencies");
int depCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL)).count());
int optionalDepCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL.negate())).count());
dependencies = getPresizedMutableMap(depCount);
optionalDependencies = getPresizedMutableMap(optionalDepCount);
for(Object jo : o.getJSONArray("dependencies")) {
JSONObject depObj = (JSONObject) jo;
// Make sure there's a name attribute and that the optional value isn't true.
String depName = Util.intern(get(depObj,"name"));
if (depName!=null) {
if (get(depObj, "optional").equals("false")) {
dependencies.put(depName, Util.intern(get(depObj, "version")));
} else {
optionalDependencies.put(depName, Util.intern(get(depObj, "version")));
}
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @param o the {@link JSONObject} representing the warning
* @throws JSONException if the argument does not match the expected format
*/
@Restricted(NoExternalUse.class)
public Warning(JSONObject o) {
try {
this.type = Type.valueOf(o.getString("type").toUpperCase(Locale.US));
} catch (IllegalArgumentException ex) {
this.type = Type.UNKNOWN;
}
this.id = o.getString("id");
this.component = Util.intern(o.getString("name"));
this.message = o.getString("message");
this.url = o.getString("url");
if (o.has("versions")) {
JSONArray versions = o.getJSONArray("versions");
List<WarningVersionRange> ranges = new ArrayList<>(versions.size());
for (int i = 0; i < versions.size(); i++) {
WarningVersionRange range = new WarningVersionRange(versions.getJSONObject(i));
ranges.add(range);
}
this.versionRanges = Collections.unmodifiableList(ranges);
} else {
this.versionRanges = Collections.emptyList();
}
}
代码示例来源:origin: jenkinsci/jenkins
Data(JSONObject o) {
this.sourceId = Util.intern((String)o.get("id"));
JSONObject c = o.optJSONObject("core");
if (c!=null) {
plugins.put(Util.intern(e.getKey()), p);
代码示例来源:origin: org.jvnet.hudson.main/maven-plugin
/**
* Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help
* with memory consumption.
*
* TODO: better if XStream has a declarative way of marking fields as "target for intern".
*/
ExecutedMojo readResolve() {
return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest));
}
代码示例来源:origin: jenkinsci/maven-plugin
/**
* Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help
* with memory consumption.
*
* TODO: better if XStream has a declarative way of marking fields as "target for intern".
*/
protected Object readResolve() {
return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest));
}
代码示例来源:origin: jenkinsci/maven-plugin
public void setMavenVersionUsed( String mavenVersionUsed ) throws IOException {
this.mavenVersionUsed = Util.intern(mavenVersionUsed);
save();
}
内容来源于网络,如有侵权,请联系作者删除!