org.xwiki.rendering.listener.reference.ResourceReference.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(112)

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

ResourceReference.<init>介绍

暂无

代码示例

代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-syntax-xhtml

/**
 * Recognize the passed reference and figure out what type of link it should be:
 * <ul>
 *   <li>UC1: the reference points to a valid URL, we return a reference of type "url",
 *       e.g. {@code http://server/path/reference#anchor}</li>
 *   <li>UC2: the reference is not a valid URL, we return a reference of type "path",
 *       e.g. {@code path/reference#anchor}</li>
 * </ul>
 *
 * @param rawReference the full reference (e.g. "/some/path/something#other")
 * @return the properly typed {@link ResourceReference} matching the use cases
 */
private ResourceReference computeResourceReference(String rawReference)
{
  ResourceReference reference;
  // Do we have a valid URL?
  Matcher matcher = URL_SCHEME_PATTERN.matcher(rawReference);
  if (matcher.lookingAt()) {
    // We have UC1
    reference = new ResourceReference(rawReference, ResourceType.URL);
  } else {
    // We have UC2
    reference = new ResourceReference(rawReference, ResourceType.PATH);
  }
  return reference;
}

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api

/**
   * {@inheritDoc}
   *
   * @see org.xwiki.rendering.parser.ResourceReferenceTypeParser#parse(String)
   */
  public ResourceReference parse(String reference)
  {
    return new ResourceReference(reference, getType());
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api

/**
   * {@inheritDoc}
   *
   * @see AbstractURIResourceReferenceTypeParser#parse(String)
   */
  @Override
  public ResourceReference parse(String reference)
  {
    ResourceReference resultReference = null;
    Matcher matcher = URL_SCHEME_PATTERN.matcher(reference);
    if (matcher.lookingAt()) {
      // We don't parse the URL since it can contain unknown protocol for the JVM but protocols known by the
      // browser (such as skype:// for example).
      resultReference = new ResourceReference(reference, getType());
    }
    return resultReference;
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api

/**
 * {@inheritDoc}
 *
 * @see org.xwiki.rendering.parser.ResourceReferenceParser#parse(String)
 */
public ResourceReference parse(String rawReference)
{
  ResourceType type;
  if (rawReference.startsWith("http://") || !isInWikiMode()) {
    type = ResourceType.URL;
  } else {
    type = ResourceType.ATTACHMENT;
  }
  ResourceReference result = new ResourceReference(rawReference, type);
  result.setTyped(false);
  return result; 
}

代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-syntax-doxia

@Override
public void figureGraphics(String source, SinkEventAttributes attributes)
{
  flushEmptyLines();
  // TODO: Handle image to attachments. For now we only handle URLs.
  getListener().onImage(new ResourceReference(source, ResourceType.URL), false, Listener.EMPTY_PARAMETERS);
}

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api

ResourceReference resourceReference = new ResourceReference(rawReference, ResourceType.URL);
  resourceReference.setTyped(false);
  return resourceReference;
return new ResourceReference(rawReference, ResourceType.UNKNOWN);

代码示例来源:origin: org.xwiki.platform/xwiki-platform-chart-macro

@Override
public List<Block> execute(ChartMacroParameters macroParams, String content, MacroTransformationContext context)
  throws MacroExecutionException
{
  // Generate the chart image in a temporary location.
  generateChart(macroParams, content, context);
  String imageLocation = this.imageWriter.getURL(new ImageId(macroParams));
  String title = macroParams.getTitle();
  ResourceReference reference = new ResourceReference(imageLocation, ResourceType.URL);
  ImageBlock imageBlock = new ImageBlock(new ResourceReference(imageLocation, ResourceType.URL), true);
  imageBlock.setParameter("alt", title);
  LinkBlock linkBlock = new LinkBlock(Collections.singletonList((Block) imageBlock), reference, true);
  linkBlock.setParameter("title", title);
  // If the macro is used standalone then we need to wrap it in a paragraph block.
  Block resultBlock;
  if (context.isInline()) {
    resultBlock = linkBlock;
  } else {
    resultBlock = new ParagraphBlock(Collections.singletonList((Block) linkBlock));
  }
  return Collections.singletonList(resultBlock);
}

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api

/**
 * {@inheritDoc}
 *
 * @see org.xwiki.rendering.parser.ResourceReferenceParser#parse(java.lang.String)
 */
public ResourceReference parse(String rawReference)
{
  // Step 1: If we're not in wiki mode then all links are URL links.
  if (!isInWikiMode()) {
    ResourceReference resourceReference = new ResourceReference(rawReference, ResourceType.URL);
    resourceReference.setTyped(false);
    return resourceReference;
  }
  // Step 2: Check if it's a known URI by looking for one of the known URI schemes. If not, check if it's a URL.
  ResourceReference resourceReference = parseURILinks(rawReference);
  if (resourceReference != null) {
    return resourceReference;
  }
  // Step 3: Look for an InterWiki link
  StringBuffer content = new StringBuffer(rawReference);
  resourceReference = parseInterWikiLinks(content);
  if (resourceReference != null) {
    return resourceReference;
  }
  // Step 4: Consider that we have a reference to a document.
  return parseDocumentLink(content);
}

代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-syntax-xhtml

@Override
  public ResourceReference parse(String rawReference)
  {
    String[] tokens = StringUtils.splitByWholeSeparatorPreserveAllTokens(rawReference, COMMENT_SEPARATOR);
    boolean isTyped = "true".equalsIgnoreCase(tokens[0]);
    ResourceType type = new ResourceType(tokens[1]);
    String reference = tokens[2];

    ResourceReference resourceReference = new ResourceReference(reference, type);
    resourceReference.setTyped(isTyped);

    if (tokens.length == 4) {
      for (WikiParameter parameter : WikiParameters.newWikiParameters(tokens[3])) {
        resourceReference.setParameter(parameter.getKey(), parameter.getValue());
      }
    }

    return resourceReference;
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-office-viewer

this.urlTemporaryResourceReferenceSerializer.serialize(temporaryResourceReference).serialize();
ResourceReference urlImageReference =
  new ResourceReference(temporaryResourceURL, ResourceType.PATH);
urlImageReference.setTyped(true);

代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-syntax-wikimodel

/**
   * {@inheritDoc}
   * @see org.xwiki.rendering.parser.ResourceReferenceParser#parse(String)
   */
  public ResourceReference parse(String rawReference)
  {
    String[] tokens = StringUtils.splitByWholeSeparatorPreserveAllTokens(rawReference, COMMENT_SEPARATOR);
    boolean isTyped = tokens[0].equalsIgnoreCase("true") ? true : false;
    ResourceType type = new ResourceType(tokens[1]);
    String reference = tokens[2];

    ResourceReference resourceReference = new ResourceReference(reference, type);
    resourceReference.setTyped(isTyped);

    if (tokens.length == 4) {
      for (WikiParameter parameter : WikiParameters.newWikiParameters(tokens[3])) {
        resourceReference.setParameter(parameter.getKey(), parameter.getValue());
      }
    }

    return resourceReference;
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-dashboard-macro

String editURL = xContext.getWiki().getURL(sourceDoc, "save", "", "", xContext);
LinkBlock editURLBlock =
  new LinkBlock(Collections.<Block> emptyList(), new ResourceReference(editURL, ResourceType.URL), false);
editURLBlock.setParameter(classParameterName, DashboardMacro.EDIT_URL);
metadataContainer.addChild(editURLBlock);
String removeURL = xContext.getWiki().getURL(sourceDoc, "objectremove", "", "", xContext);
LinkBlock removeURLBlock =
  new LinkBlock(Collections.<Block> emptyList(), new ResourceReference(removeURL, ResourceType.URL), false);
removeURLBlock.setParameter(classParameterName, DashboardMacro.REMOVE_URL);
metadataContainer.addChild(removeURLBlock);
String addURL = xContext.getWiki().getURL(sourceDoc, "objectadd", "", "", xContext);
LinkBlock addURLBlock =
  new LinkBlock(Collections.<Block> emptyList(), new ResourceReference(addURL, ResourceType.URL), false);
addURLBlock.setParameter(classParameterName, DashboardMacro.ADD_URL);
metadataContainer.addChild(addURLBlock);
String sourceURL = xContext.getWiki().getURL(sourceDoc, "view", "", "", xContext);
LinkBlock sourceURLBlock =
  new LinkBlock(Collections.<Block> emptyList(), new ResourceReference(sourceURL, ResourceType.URL), false);
sourceURLBlock.setParameter(classParameterName, DashboardMacro.SOURCE_URL);
metadataContainer.addChild(sourceURLBlock);

代码示例来源:origin: org.xwiki.platform/xwiki-platform-formula-macro

ResourceReference imageReference = new ResourceReference(url, ResourceType.URL);
ImageBlock result = new ImageBlock(imageReference, false);

代码示例来源:origin: org.xwiki.platform/xwiki-platform-rendering-macro-useravatar

new ResourceReference(this.skinAccessBridge.getSkinFile("icons/xwiki/noavatar.png"), ResourceType.URL);
      new ResourceReference(this.compactWikiEntityReferenceSerializer.serialize(attachmentReference),
        ResourceType.ATTACHMENT);

相关文章