com.cloudinary.Url.clone()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(111)

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

Url.clone介绍

暂无

代码示例

代码示例来源:origin: cloudinary/cloudinary_java

private void appendVideoSources(StringBuilder html, String source, String sourceType) {
  Url sourceUrl = this.clone();
  if (this.sourceTransformation != null) {
    Transformation transformation = this.transformation;
    Transformation sourceTransformation = null;
    if (this.sourceTransformation.get(sourceType) != null)
      sourceTransformation = new Transformation(this.sourceTransformation.get(sourceType));
    if (transformation == null) {
      transformation = sourceTransformation;
    } else if (sourceTransformation != null) {
      transformation = transformation.chainWith(sourceTransformation);
    }
    sourceUrl.transformation(transformation);
  }
  String src = sourceUrl.format(sourceType).generate(source);
  String videoType = sourceType;
  if (sourceType.equals("ogv"))
    videoType = "ogg";
  String mimeType = "video/" + videoType;
  html.append("<source src='").append(src).append("' type='").append(mimeType).append("'>");
}

代码示例来源:origin: com.cloudinary/cloudinary-core

private void appendVideoSources(StringBuilder html, String source, String sourceType) {
  Url sourceUrl = this.clone();
  if (this.sourceTransformation != null) {
    Transformation transformation = this.transformation;
    Transformation sourceTransformation = null;
    if (this.sourceTransformation.get(sourceType) != null)
      sourceTransformation = new Transformation(this.sourceTransformation.get(sourceType));
    if (transformation == null) {
      transformation = sourceTransformation;
    } else if (sourceTransformation != null) {
      transformation = transformation.chainWith(sourceTransformation);
    }
    sourceUrl.transformation(transformation);
  }
  String src = sourceUrl.format(sourceType).generate(source);
  String videoType = sourceType;
  if (sourceType.equals("ogv"))
    videoType = "ogg";
  String mimeType = "video/" + videoType;
  html.append("<source src='").append(src).append("' type='").append(mimeType).append("'>");
}

代码示例来源:origin: com.cloudinary/cloudinary-core

public Url clone() {
  Url cloned = cloudinary.url();
  cloned.config.update(config.asMap());
  cloned.fallbackContent = this.fallbackContent;
  cloned.format = this.format;
  cloned.posterSource = this.posterSource;
  if (this.posterTransformation != null)
    cloned.posterTransformation = new Transformation(this.posterTransformation);
  if (this.posterUrl != null) cloned.posterUrl = this.posterUrl.clone();
  cloned.publicId = this.publicId;
  cloned.resourceType = this.resourceType;
  cloned.signUrl = this.signUrl;
  cloned.source = this.source;
  if (this.transformation != null) cloned.transformation = new Transformation(this.transformation);
  if (this.sourceTransformation != null) {
    cloned.sourceTransformation = new HashMap<String, Transformation>();
    for (Map.Entry<String, Transformation> keyValuePair : this.sourceTransformation.entrySet()) {
      cloned.sourceTransformation.put(keyValuePair.getKey(), keyValuePair.getValue());
    }
  }
  cloned.sourceTypes = this.sourceTypes;
  cloned.urlSuffix = this.urlSuffix;
  cloned.useRootPath = this.useRootPath;
  return cloned;
}

代码示例来源:origin: cloudinary/cloudinary_java

public Url clone() {
  Url cloned = cloudinary.url();
  cloned.config.update(config.asMap());
  cloned.fallbackContent = this.fallbackContent;
  cloned.format = this.format;
  cloned.posterSource = this.posterSource;
  if (this.posterTransformation != null)
    cloned.posterTransformation = new Transformation(this.posterTransformation);
  if (this.posterUrl != null) cloned.posterUrl = this.posterUrl.clone();
  cloned.publicId = this.publicId;
  cloned.resourceType = this.resourceType;
  cloned.signUrl = this.signUrl;
  cloned.source = this.source;
  if (this.transformation != null) cloned.transformation = new Transformation(this.transformation);
  if (this.sourceTransformation != null) {
    cloned.sourceTransformation = new HashMap<String, Transformation>();
    for (Map.Entry<String, Transformation> keyValuePair : this.sourceTransformation.entrySet()) {
      cloned.sourceTransformation.put(keyValuePair.getKey(), keyValuePair.getValue());
    }
  }
  cloned.sourceTypes = this.sourceTypes;
  cloned.urlSuffix = this.urlSuffix;
  cloned.useRootPath = this.useRootPath;
  return cloned;
}

代码示例来源:origin: com.cloudinary/cloudinary-core

private String finalizePosterUrl(String source) {
  String posterUrl = null;
  if (this.posterUrl != null) {
    posterUrl = this.posterUrl.generate();
  } else if (this.posterTransformation != null) {
    posterUrl = this.clone().format("jpg").transformation(new Transformation(this.posterTransformation))
        .generate(source);
  } else if (this.posterSource != null) {
    if (!StringUtils.isEmpty(this.posterSource))
      posterUrl = this.clone().format("jpg").generate(this.posterSource);
  } else {
    posterUrl = this.clone().format("jpg").generate(source);
  }
  return posterUrl;
}

代码示例来源:origin: cloudinary/cloudinary_java

private String finalizePosterUrl(String source) {
  String posterUrl = null;
  if (this.posterUrl != null) {
    posterUrl = this.posterUrl.generate();
  } else if (this.posterTransformation != null) {
    posterUrl = this.clone().format("jpg").transformation(new Transformation(this.posterTransformation))
        .generate(source);
  } else if (this.posterSource != null) {
    if (!StringUtils.isEmpty(this.posterSource))
      posterUrl = this.clone().format("jpg").generate(this.posterSource);
  } else {
    posterUrl = this.clone().format("jpg").generate(source);
  }
  return posterUrl;
}

代码示例来源:origin: cloudinary/cloudinary_android

/**
 * Construct the final url with the dimensions included as the last transformation in the url.
 * @param view      The view to adapt the image size to.
 * @param baseUrl   The base cloudinary Url to chain the transformation to.
 * @return The url with the responsive transformation.
 */
private Url buildUrl(View view, Url baseUrl) {
  // add a new transformation on top of anything already there:
  Url url = baseUrl.clone();
  url.transformation().chain();
  if (autoHeight) {
    int contentHeight = view.getHeight() - view.getPaddingTop() - view.getPaddingBottom();
    url.transformation().height(trimAndRoundUp(contentHeight));
  }
  if (autoWidth) {
    int contentWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
    url.transformation().width(trimAndRoundUp(contentWidth));
  }
  url.transformation().crop(cropMode).gravity(gravity);
  return url;
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
  public void testUrlCloneConfig(){
    // verify that secure (from url.config) is cloned as well:
    Url url = cloudinary.url().cloudName("cloud").format("frmt").publicId("123").secure(true);
    assertEquals("https://res.cloudinary.com/cloud/image/upload/123.frmt", url.clone().generate());
  }
}

相关文章