本文整理了Java中org.xwiki.rendering.syntax.Syntax
类的一些代码示例,展示了Syntax
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Syntax
类的具体详情如下:
包路径:org.xwiki.rendering.syntax.Syntax
类名称:Syntax
[英]Represents a wiki syntax that the user can use to enter wiki content. A syntax is made of two parts: a type (eg XWiki, Confluence, MediaWiki, etc) and a version (1.0, 2.0, etc). For example the XWiki 1.0 syntax, the XWiki 2.0 syntax, the Confluence 1.0 syntax, etc.
[中]表示用户可用于输入wiki内容的wiki语法。语法由两部分组成:一个类型(如XWiki、Confluence、MediaWiki等)和一个版本(1.0、2.0等)。例如,XWiki 1.0语法、XWiki 2.0语法、Confluence 1.0语法等。
代码示例来源:origin: org.xwiki.platform/xwiki-platform-filter-stream-xar
public String toString(Syntax syntax)
{
return syntax != null ? syntax.toIdString() : null;
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
@Override
public boolean match(MacroId macroId)
{
// True if the macroId has no syntax or if it has one it has to match the passed syntax
return syntax == null || macroId.getSyntax() == null || macroId.getSyntax().equals(syntax);
}
}).get(category);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-rendering-configuration-default
private List<Syntax> convertList(List<String> syntaxesAsStrings)
{
if (syntaxesAsStrings == null) {
return null;
}
List<Syntax> syntaxes = new ArrayList<>();
for (String syntaxAsString : syntaxesAsStrings) {
try {
syntaxes.add(Syntax.valueOf(syntaxAsString));
} catch (ParseException e) {
throw new RuntimeException(String.format("Failed to convert [%s] into Syntax object", syntaxAsString),
e);
}
}
return syntaxes;
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see Object#toString()
*/
@Override
public String toString()
{
return getType().toString() + " " + getVersion() + (getQualifier() != null ? " (" + getQualifier() + ")" : "");
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
public String toIdString()
{
return getType().getId() + "/" + getVersion().toLowerCase();
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* @return the {@link StreamParser} to use to parser the input content
*/
protected StreamParser getStreamParser()
{
StreamParser streamParser;
try {
streamParser = this.componentManager.lookup(StreamParser.class, getSyntax().toIdString());
} catch (ComponentLookupException e) {
throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
}
return streamParser;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
StringBuffer result = new StringBuffer();
super.displayView(result, name, prefix, object, context);
if (getObjectDocumentSyntax(object, context).equals(Syntax.XWIKI_1_0)) {
buffer.append(context.getWiki().parseContent(result.toString(), context));
} else {
if (doc != null) {
buffer.append(doc.getRenderedContent(result.toString(),
getObjectDocumentSyntax(object, context).toIdString(), context));
} else {
buffer.append(result);
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see AbstractChainingPrintRenderer#onRawText(String, Syntax)
*/
@Override
public void onRawText(String text, Syntax syntax)
{
// Directly inject the HTML content in the wiki printer (bypassing the XHTML printer)
if ((syntax.getType() == SyntaxType.XHTML) || (syntax.getType() == SyntaxType.HTML)) {
getXHTMLWikiPrinter().printRaw(text);
}
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
if (!outputSyntax.equals(Syntax.HTML_4_01) && !outputSyntax.equals(Syntax.XHTML_1_0)) {
XDOM xdom = parseContent(Syntax.HTML_4_01.toIdString(), title);
this.parserUtils.removeTopLevelParagraph(xdom.getChildren());
title = renderXDOM(xdom, outputSyntax);
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see PrintRendererFactory#createRenderer(org.xwiki.rendering.renderer.printer.WikiPrinter)
*/
public PrintRenderer createRenderer(WikiPrinter printer)
{
PrintRenderer renderer;
try {
renderer = this.componentManager.lookup(PrintRenderer.class, getSyntax().toIdString());
} catch (ComponentLookupException e) {
throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
}
renderer.setPrinter(printer);
return renderer;
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see Object#hashCode()
*/
@Override
public int hashCode()
{
// Random number. See http://www.technofundo.com/tech/java/equalhash.html for the detail of this
// algorithm.
int hash = 7;
hash = 31 * hash + (null == getType() ? 0 : getType().hashCode());
hash = 31 * hash + (null == getVersion() ? 0 : getVersion().hashCode());
hash = 31 * hash + (null == getQualifier() ? 0 : getQualifier().hashCode());
return hash;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
Syntax factorySyntax = factory.getSyntax();
if (syntaxVersion != null) {
if (factorySyntax.getType().getId().equalsIgnoreCase(syntaxType)
&& factorySyntax.getVersion().equals(syntaxVersion)) {
syntax = factorySyntax;
break;
if (factorySyntax.getType().getId().equalsIgnoreCase(syntaxType)
&& (syntax == null || factorySyntax.getVersion().compareTo(syntax.getVersion()) > 0)) {
syntax = factorySyntax;
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-syntax-xhtml
@Override
public void onRawText(String text, Syntax syntax)
{
// Directly inject the HTML content in the wiki printer (bypassing the XHTML printer)
if ((syntax.getType().equals(SyntaxType.XHTML)) || (syntax.getType().equals(SyntaxType.HTML))) {
getXHTMLWikiPrinter().printRaw(text);
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @return true if the document has a xwiki/1.0 syntax content
*/
public boolean is10Syntax(String syntaxId)
{
return Syntax.XWIKI_1_0.toIdString().equalsIgnoreCase(syntaxId);
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
@Override
public boolean match(MacroId macroId)
{
// True if the macroId has no syntax or if it has one it has to match the passed syntax
return syntax == null || macroId.getSyntax() == null || macroId.getSyntax().equals(syntax);
}
}).keySet();
代码示例来源:origin: org.xwiki.platform/xwiki-platform-filter-stream-xar
protected <T> T convert(Class<?> type, String source) throws FilterException
{
Object value = source;
if (type == Locale.class) {
value = toLocale(source);
} else if (type == Date.class) {
value = StringUtils.isNotEmpty(source) ? new Date(Long.parseLong(source)) : null;
} else if (type == Boolean.class) {
value = StringUtils.isNotEmpty(source) ? Boolean.parseBoolean(source) : null;
} else if (type == Syntax.class) {
if (StringUtils.isNotEmpty(source)) {
try {
value = Syntax.valueOf(source);
} catch (ParseException e) {
throw new FilterException(String.format("Failed to create Syntax istance for [%s]", source), e);
}
} else {
value = null;
}
} else if (type == Integer.class) {
value = StringUtils.isNotEmpty(source) ? Integer.parseInt(source) : null;
}
return (T) value;
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object object)
{
boolean result;
// See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
if (this == object) {
result = true;
} else {
if ((object == null) || (object.getClass() != this.getClass())) {
result = false;
} else {
// object must be Syntax at this point
Syntax syntax = (Syntax) object;
result =
(getType() == syntax.getType() || (getType() != null && getType().equals(syntax.getType())))
&& (getVersion() == syntax.getVersion() || (getVersion() != null && getVersion().equals(
syntax.getVersion())))
&& (getQualifier() == syntax.getQualifier() || (getQualifier() != null && getQualifier().equals(
syntax.getQualifier())));
}
}
return result;
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param text the text to render
* @param syntaxId the id of the Syntax used by the passed text (for example: "xwiki/1.0")
* @param context the XWiki Context object
* @return the given text rendered in the context of this document using the passed Syntax
* @since 1.6M1
*/
public String getRenderedContent(String text, String syntaxId, XWikiContext context)
{
return getRenderedContent(text, syntaxId, Syntax.XHTML_1_0.toIdString(), context);
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-transformation-macro
public boolean match(MacroId macroId)
{
// True if the macroId has no syntax or if it has one it has to match the passed syntax
return syntax == null || macroId.getSyntax() == null || macroId.getSyntax().equals(syntax);
}
}).get(category);
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
@Override
public MacroId createMacroId(String macroIdAsString) throws ParseException
{
MacroId macroId;
// Verify if we have a syntax specified.
String[] hintParts = macroIdAsString.split("/");
if (hintParts.length == 3) {
// We've found a macro id for a macro that should be available only for a given syntax
Syntax syntax;
try {
syntax = Syntax.valueOf(String.format("%s/%s", hintParts[1], hintParts[2]));
} catch (ParseException e) {
throw new ParseException(String.format(INVALID_MACRO_ID_FORMAT, macroIdAsString), e);
}
macroId = new MacroId(hintParts[0], syntax);
} else if (hintParts.length == 1) {
// We've found a macro registered for all syntaxes
macroId = new MacroId(macroIdAsString);
} else {
// Invalid format
throw new ParseException(String.format(INVALID_MACRO_ID_FORMAT, macroIdAsString));
}
return macroId;
}
}
内容来源于网络,如有侵权,请联系作者删除!