hudson.Util.intern()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中hudson.Util.intern()方法的一些代码示例,展示了Util.intern()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.intern()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:intern

Util.intern介绍

[英]Null-safe String intern method.
[中]空安全字符串实习生方法。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. /** Returns the input strings, but with all values interned. */
  2. public static String[] internInPlace(String[] input) {
  3. if (input == null) {
  4. return null;
  5. } else if (input.length == 0) {
  6. return EMPTY_STRING_ARRAY;
  7. }
  8. for (int i=0; i<input.length; i++) {
  9. input[i] = Util.intern(input[i]);
  10. }
  11. return input;
  12. }

代码示例来源:origin: jenkinsci/jenkins

  1. public Dependency(String s) {
  2. int idx = s.indexOf(':');
  3. if(idx==-1)
  4. throw new IllegalArgumentException("Illegal dependency specifier "+s);
  5. this.shortName = Util.intern(s.substring(0,idx));
  6. String version = Util.intern(s.substring(idx+1));
  7. boolean isOptional = false;
  8. String[] osgiProperties = version.split("[;]");
  9. for (int i = 1; i < osgiProperties.length; i++) {
  10. String osgiProperty = osgiProperties[i].trim();
  11. if (osgiProperty.equalsIgnoreCase("resolution:=optional")) {
  12. isOptional = true;
  13. }
  14. }
  15. this.optional = isOptional;
  16. if (isOptional) {
  17. this.version = osgiProperties[0];
  18. } else {
  19. this.version = version;
  20. }
  21. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * @param archive
  3. * A .jpi archive file jar file, or a .jpl linked plugin.
  4. * @param manifest
  5. * The manifest for the plugin
  6. * @param baseResourceURL
  7. * A URL pointing to the resources for this plugin
  8. * @param classLoader
  9. * a classloader that loads classes from this plugin and its dependencies
  10. * @param disableFile
  11. * if this file exists on startup, the plugin will not be activated
  12. * @param dependencies a list of mandatory dependencies
  13. * @param optionalDependencies a list of optional dependencies
  14. */
  15. public PluginWrapper(PluginManager parent, File archive, Manifest manifest, URL baseResourceURL,
  16. ClassLoader classLoader, File disableFile,
  17. List<Dependency> dependencies, List<Dependency> optionalDependencies) {
  18. this.parent = parent;
  19. this.manifest = manifest;
  20. this.shortName = Util.intern(computeShortName(manifest, archive.getName()));
  21. this.baseResourceURL = baseResourceURL;
  22. this.classLoader = classLoader;
  23. this.disableFile = disableFile;
  24. this.active = !disableFile.exists();
  25. this.dependencies = dependencies;
  26. this.optionalDependencies = optionalDependencies;
  27. this.archive = archive;
  28. }

代码示例来源:origin: jenkinsci/jenkins

  1. public WarningVersionRange(JSONObject o) {
  2. this.name = Util.fixEmpty(o.optString("name"));
  3. this.firstVersion = Util.intern(Util.fixEmpty(o.optString("firstVersion")));
  4. this.lastVersion = Util.intern(Util.fixEmpty(o.optString("lastVersion")));
  5. Pattern p;
  6. try {
  7. p = Pattern.compile(o.getString("pattern"));
  8. } catch (PatternSyntaxException ex) {
  9. LOGGER.log(Level.WARNING, "Failed to compile pattern '" + o.getString("pattern") + "', using '.*' instead", ex);
  10. p = Pattern.compile(".*");
  11. }
  12. this.pattern = p;
  13. }

代码示例来源:origin: jenkinsci/jenkins

  1. Entry(String sourceId, JSONObject o, String baseURL) {
  2. this.sourceId = sourceId;
  3. this.name = Util.intern(o.getString("name"));
  4. this.version = Util.intern(o.getString("version"));
  5. // Trim this to prevent issues when the other end used Base64.encodeBase64String that added newlines
  6. // to the end in old commons-codec. Not the case on updates.jenkins-ci.org, but let's be safe.
  7. this.sha1 = Util.fixEmptyAndTrim(o.optString("sha1"));
  8. this.sha256 = Util.fixEmptyAndTrim(o.optString("sha256"));
  9. this.sha512 = Util.fixEmptyAndTrim(o.optString("sha512"));
  10. String url = o.getString("url");
  11. if (!URI.create(url).isAbsolute()) {
  12. if (baseURL == null) {
  13. throw new IllegalArgumentException("Cannot resolve " + url + " without a base URL");
  14. }
  15. url = URI.create(baseURL).resolve(url).toString();
  16. }
  17. this.url = url;
  18. }

代码示例来源:origin: jenkinsci/jenkins

  1. @DataBoundConstructor
  2. public Plugin(String sourceId, JSONObject o) {
  3. super(sourceId, o, UpdateSite.this.url);
  4. this.wiki = get(o,"wiki");
  5. this.title = get(o,"title");
  6. this.excerpt = get(o,"excerpt");
  7. this.compatibleSinceVersion = Util.intern(get(o,"compatibleSinceVersion"));
  8. this.minimumJavaVersion = Util.intern(get(o, "minimumJavaVersion"));
  9. this.requiredCore = Util.intern(get(o,"requiredCore"));
  10. this.categories = o.has("labels") ? internInPlace((String[])o.getJSONArray("labels").toArray(EMPTY_STRING_ARRAY)) : null;
  11. JSONArray ja = o.getJSONArray("dependencies");
  12. int depCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL)).count());
  13. int optionalDepCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL.negate())).count());
  14. dependencies = getPresizedMutableMap(depCount);
  15. optionalDependencies = getPresizedMutableMap(optionalDepCount);
  16. for(Object jo : o.getJSONArray("dependencies")) {
  17. JSONObject depObj = (JSONObject) jo;
  18. // Make sure there's a name attribute and that the optional value isn't true.
  19. String depName = Util.intern(get(depObj,"name"));
  20. if (depName!=null) {
  21. if (get(depObj, "optional").equals("false")) {
  22. dependencies.put(depName, Util.intern(get(depObj, "version")));
  23. } else {
  24. optionalDependencies.put(depName, Util.intern(get(depObj, "version")));
  25. }
  26. }
  27. }
  28. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. *
  3. * @param o the {@link JSONObject} representing the warning
  4. * @throws JSONException if the argument does not match the expected format
  5. */
  6. @Restricted(NoExternalUse.class)
  7. public Warning(JSONObject o) {
  8. try {
  9. this.type = Type.valueOf(o.getString("type").toUpperCase(Locale.US));
  10. } catch (IllegalArgumentException ex) {
  11. this.type = Type.UNKNOWN;
  12. }
  13. this.id = o.getString("id");
  14. this.component = Util.intern(o.getString("name"));
  15. this.message = o.getString("message");
  16. this.url = o.getString("url");
  17. if (o.has("versions")) {
  18. JSONArray versions = o.getJSONArray("versions");
  19. List<WarningVersionRange> ranges = new ArrayList<>(versions.size());
  20. for (int i = 0; i < versions.size(); i++) {
  21. WarningVersionRange range = new WarningVersionRange(versions.getJSONObject(i));
  22. ranges.add(range);
  23. }
  24. this.versionRanges = Collections.unmodifiableList(ranges);
  25. } else {
  26. this.versionRanges = Collections.emptyList();
  27. }
  28. }

代码示例来源:origin: jenkinsci/jenkins

  1. Data(JSONObject o) {
  2. this.sourceId = Util.intern((String)o.get("id"));
  3. JSONObject c = o.optJSONObject("core");
  4. if (c!=null) {
  5. plugins.put(Util.intern(e.getKey()), p);

代码示例来源:origin: org.jvnet.hudson.main/maven-plugin

  1. /**
  2. * Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help
  3. * with memory consumption.
  4. *
  5. * TODO: better if XStream has a declarative way of marking fields as "target for intern".
  6. */
  7. ExecutedMojo readResolve() {
  8. return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest));
  9. }

代码示例来源:origin: jenkinsci/maven-plugin

  1. /**
  2. * Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help
  3. * with memory consumption.
  4. *
  5. * TODO: better if XStream has a declarative way of marking fields as "target for intern".
  6. */
  7. protected Object readResolve() {
  8. return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest));
  9. }

代码示例来源:origin: jenkinsci/maven-plugin

  1. public void setMavenVersionUsed( String mavenVersionUsed ) throws IOException {
  2. this.mavenVersionUsed = Util.intern(mavenVersionUsed);
  3. save();
  4. }

相关文章