Tabnine Logo
XDOM.getMetaData
Code IndexAdd Tabnine to your IDE (free)

How to use
getMetaData
method
in
org.xwiki.rendering.block.XDOM

Best Java code snippets using org.xwiki.rendering.block.XDOM.getMetaData (Showing top 10 results out of 315)

origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Convert the passed content from the passed syntax to the passed new syntax.
 * 
 * @param content the content to convert
 * @param source the reference to where the content comes from (eg document reference)
 * @param targetSyntax the new syntax after the conversion
 * @param txContext the context when Transformation are executed or null if transformation shouldn't be executed
 * @return the converted content in the new syntax
 * @throws XWikiException if an exception occurred during the conversion process
 * @since 2.4M2
 */
private static String performSyntaxConversion(String content, String source, Syntax targetSyntax,
  TransformationContext txContext) throws XWikiException
{
  try {
    XDOM dom = parseContent(txContext.getSyntax().toIdString(), content);
    // Set the source metadata for the parsed XDOM so that Renderers can resolve relative links/images based
    // on it.
    dom.getMetaData().addMetaData(MetaData.SOURCE, source);
    return performSyntaxConversion(dom, targetSyntax, txContext);
  } catch (Exception e) {
    throw new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, XWikiException.ERROR_XWIKI_UNKNOWN,
      "Failed to convert document to syntax [" + targetSyntax + "]", e);
  }
}
origin: org.xwiki.platform/xwiki-platform-rendering-async-api

  private Block tranform(XDOM xdom, Block block) throws RenderingException
  {
    TransformationContext transformationContext =
      new TransformationContext(xdom, this.configuration.getDefaultSyntax(), false);
    transformationContext.setTargetSyntax(this.configuration.getTargetSyntax());
    transformationContext.setId(this.configuration.getTransformationId());

    transform(block, transformationContext);

    // The result is often inserted in a bigger content so we remove the XDOM around it
    if (block instanceof XDOM) {
      return new MetaDataBlock(block.getChildren(), ((XDOM) block).getMetaData());
    }

    return block;
  }
}
origin: org.xwiki.platform/xwiki-platform-display-api

/**
 * Displays the given document in the current execution context.
 * 
 * @param document the document to display
 * @param nameSpace the name-space to be used when performing the display transformations
 * @param parameters the display parameters
 * @return the result of displaying the given document
 */
protected XDOM display(DocumentModelBridge document, String nameSpace, DocumentDisplayerParameters parameters)
{
  // This is a clone of the cached content that can be safely modified.
  XDOM content = getContent(document, parameters);
  if (!parameters.isContentTransformed()) {
    return content;
  }
  // Before executing the XDOM transformations make sure the references used by them (e.g. the 'reference'
  // parameter of the Include macro) are resolved relative to the current document on the execution context.
  content.getMetaData().addMetaData(MetaData.BASE,
    defaultEntityReferenceSerializer.serialize(documentAccessBridge.getCurrentDocumentReference()));
  TransformationContext txContext =
    new TransformationContext(content, document.getSyntax(), parameters.isTransformationContextRestricted());
  txContext.setId(nameSpace);
  try {
    transformationManager.performTransformations(content, txContext);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
  return content;
}
origin: org.xwiki.rendering/xwiki-rendering-transformation-macro

/**
 * creates XDOM.
 */
private XDOM createXDOM(String content, MacroTransformationContext macroContext, boolean transform,
  MetaData metadata, boolean inline, Syntax syntax) throws MacroExecutionException
{
  try {
    XDOM result = getSyntaxParser(syntax).parse(new StringReader(content));
    if (metadata != null) {
      result.getMetaData().addMetaData(metadata);
    }
    if (transform && macroContext.getTransformation() != null) {
      TransformationContext txContext = new TransformationContext(result, syntax);
      txContext.setId(macroContext.getId());
      performTransformation((MutableRenderingContext) this.renderingContext,
        macroContext.getTransformation(), txContext, result);
    }
    if (inline) {
      result = convertToInline(result);
    }
    return result;
  } catch (Exception e) {
    throw new MacroExecutionException("Failed to parse content [" + content + "]", e);
  }
}
origin: org.xwiki.platform/xwiki-platform-display-macro

MetaDataBlock metadata = new MetaDataBlock(result.getChildren(), result.getMetaData());
String source = this.defaultEntityReferenceSerializer.serialize(includedReference);
metadata.getMetaData().addMetaData(MetaData.SOURCE, source);
origin: org.xwiki.rendering/xwiki-rendering-tests

private void runTestInternal() throws Throwable
{
  WikiPrinter printer = new DefaultWikiPrinter();
  if (!this.streaming) {
    Parser parser = getComponentManager().lookup(Parser.class, this.parserId);
    XDOM xdom = parser.parse(new StringReader(this.input));
    if (this.runTransformations) {
      SyntaxFactory syntaxFactory = getComponentManager().lookup(SyntaxFactory.class);
      TransformationManager transformationManager = getComponentManager().lookup(TransformationManager.class);
      TransformationContext txContext =
        new TransformationContext(xdom, syntaxFactory.createSyntaxFromIdString(this.parserId));
      transformationManager.performTransformations(xdom, txContext);
    }
    BlockRenderer renderer = getComponentManager().lookup(BlockRenderer.class, this.targetSyntaxId);
    // remove source syntax from XDOM metadata
    Map<String, Object> metadataMap = new HashMap<String, Object>(xdom.getMetaData().getMetaData());
    metadataMap.remove(MetaData.SYNTAX);
    xdom = new XDOM(xdom.getChildren(), new MetaData(metadataMap));
    renderer.render(xdom, printer);
  } else {
    StreamParser parser = getComponentManager().lookup(StreamParser.class, this.parserId);
    PrintRendererFactory printRendererFactory =
      getComponentManager().lookup(PrintRendererFactory.class, this.targetSyntaxId);
    // remove source syntax from begin/endDocument metadata
    WrappingListener listener = new SyntaxWrappingListener();
    listener.setWrappedListener(printRendererFactory.createRenderer(printer));
    parser.parse(new StringReader(this.input), listener);
  }
  assertEquals(this.expected, printer.toString());
}
origin: org.xwiki.rendering/xwiki-rendering-test

if (xdom.getMetaData() != null) {
  Map<String, Object> metadataMap = new HashMap<String, Object>(xdom.getMetaData().getMetaData());
  metadataMap.remove(MetaData.SYNTAX);
  xdom = new XDOM(xdom.getChildren(), new MetaData(metadataMap));
origin: org.xwiki.platform/xwiki-platform-display-api

/**
 * Get the content to display (either the entire document content or the content of a specific section).
 * 
 * @param document the source document
 * @param parameters the display parameters
 * @return the content as an XDOM tree
 */
private XDOM getContent(DocumentModelBridge document, final DocumentDisplayerParameters parameters)
{
  XDOM content = parameters.isContentTranslated() ? getTranslatedContent(document) : document.getXDOM();
  if (parameters.getSectionId() != null) {
    HeaderBlock headerBlock =
      content.getFirstBlock(new CompositeBlockMatcher(new ClassBlockMatcher(HeaderBlock.class),
        new BlockMatcher()
        {
          @Override
          public boolean match(Block block)
          {
            return ((HeaderBlock) block).getId().equals(parameters.getSectionId());
          }
        }), Block.Axes.DESCENDANT);
    if (headerBlock == null) {
      throw new RuntimeException("Cannot find section [" + parameters.getSectionId() + "] in document ["
        + this.defaultEntityReferenceSerializer.serialize(document.getDocumentReference()) + "]");
    } else {
      content = new XDOM(headerBlock.getSection().getChildren(), content.getMetaData());
    }
  }
  return content;
}
origin: org.xwiki.platform/xwiki-platform-rendering-macro-include

MetaDataBlock metadata = new MetaDataBlock(result.getChildren(), result.getMetaData());
String source = this.defaultEntityReferenceSerializer.serialize(includedReference);
metadata.getMetaData().addMetaData(MetaData.SOURCE, source);
origin: org.xwiki.platform/xwiki-platform-rendering-wikimacro-store

new MetaDataBlock(Collections.<Block>singletonList(wikiMacroMarker), macroXDOM.getMetaData());
org.xwiki.rendering.blockXDOMgetMetaData

Popular methods of XDOM

  • getChildren
  • <init>
  • getBlocks
  • clone
  • getChildrenByType
  • setIdGenerator
  • traverse
  • addChild
  • getFirstBlock
  • getParameters
  • indexOf
  • replaceChild
  • indexOf,
  • replaceChild,
  • setChildren

Popular in Java

  • Reactive rest calls using spring rest template
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Kernel (java.awt.image)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • JComboBox (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now