org.eclipse.mylyn.wikitext.confluence.core_1.6.1.v20120425-0100

16:47:02.535 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.wikitext.confluence.core_1.6.1.v20120425-0100.jar
package org.eclipse.mylyn.wikitext.confluence.core;

import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.mylyn.internal.wikitext.confluence.core.ConfluenceDocumentBuilder;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.CodeBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ColorBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedPreformattedBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedQuoteBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.HeadingBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ListBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ParagraphBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.QuoteBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.TableBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.TableOfContentsBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.block.TextBoxBlock;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.ColorPhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.ConfluenceWrappedPhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.EmphasisPhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.HyperlinkPhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.ImagePhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.SimplePhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.SimpleWrappedPhraseModifier;
import org.eclipse.mylyn.internal.wikitext.confluence.core.token.AnchorReplacementToken;
import org.eclipse.mylyn.internal.wikitext.confluence.core.token.EscapedCharacterReplacementToken;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.SpanType;
import org.eclipse.mylyn.wikitext.core.parser.markup.AbstractMarkupLanguage;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage.PatternBasedSyntax;
import org.eclipse.mylyn.wikitext.core.parser.markup.token.EntityReferenceReplacementToken;
import org.eclipse.mylyn.wikitext.core.parser.markup.token.ImpliedHyperlinkReplacementToken;
import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternEntityReferenceReplacementToken;
import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternLineBreakReplacementToken;
import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternLiteralReplacementToken;

public class ConfluenceLanguage
  extends AbstractMarkupLanguage
{
  private final List<Block> nestedBlocks = new ArrayList();
  
  public ConfluenceLanguage()
  {
    setName("Confluence");
  }
  
  protected void clearLanguageSyntax()
  {
    super.clearLanguageSyntax();
    nestedBlocks.clear();
  }
  
  public List<Block> getNestedBlocks()
  {
    return nestedBlocks;
  }
  
  protected void addStandardBlocks(List<Block> blocks, List<Block> paragraphBreakingBlocks)
  {
    HeadingBlock headingBlock = new HeadingBlock();
    blocks.add(headingBlock);
    paragraphBreakingBlocks.add(headingBlock);
    nestedBlocks.add(headingBlock);
    ListBlock listBlock = new ListBlock();
    blocks.add(listBlock);
    paragraphBreakingBlocks.add(listBlock);
    nestedBlocks.add(listBlock);
    blocks.add(new QuoteBlock());
    TableBlock tableBlock = new TableBlock();
    blocks.add(tableBlock);
    paragraphBreakingBlocks.add(tableBlock);
    nestedBlocks.add(tableBlock);
    ExtendedQuoteBlock quoteBlock = new ExtendedQuoteBlock();
    blocks.add(quoteBlock);
    paragraphBreakingBlocks.add(quoteBlock);
    ExtendedPreformattedBlock noformatBlock = new ExtendedPreformattedBlock();
    blocks.add(noformatBlock);
    paragraphBreakingBlocks.add(noformatBlock);
    
    blocks.add(new TextBoxBlock(DocumentBuilder.BlockType.PANEL, "panel"));
    blocks.add(new TextBoxBlock(DocumentBuilder.BlockType.NOTE, "note"));
    blocks.add(new TextBoxBlock(DocumentBuilder.BlockType.INFORMATION, "info"));
    blocks.add(new TextBoxBlock(DocumentBuilder.BlockType.WARNING, "warning"));
    blocks.add(new TextBoxBlock(DocumentBuilder.BlockType.TIP, "tip"));
    CodeBlock codeBlock = new CodeBlock();
    blocks.add(codeBlock);
    paragraphBreakingBlocks.add(codeBlock);
    blocks.add(new TableOfContentsBlock());
    ColorBlock colorBlock = new ColorBlock();
    blocks.add(colorBlock);
    paragraphBreakingBlocks.add(colorBlock);
  }
  
  protected void addStandardPhraseModifiers(MarkupLanguage.PatternBasedSyntax phraseModifierSyntax)
  {
    phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\[\\]])|^)(?:", 0);
    phraseModifierSyntax.add(new HyperlinkPhraseModifier());
    phraseModifierSyntax.add(new SimplePhraseModifier("*", DocumentBuilder.SpanType.STRONG, true));
    phraseModifierSyntax.add(new EmphasisPhraseModifier());
    phraseModifierSyntax.add(new SimplePhraseModifier("??", DocumentBuilder.SpanType.CITATION, true));
    phraseModifierSyntax.add(new SimplePhraseModifier("-", DocumentBuilder.SpanType.DELETED, true));
    phraseModifierSyntax.add(new SimplePhraseModifier("+", DocumentBuilder.SpanType.UNDERLINED, true));
    phraseModifierSyntax.add(new SimplePhraseModifier("^", DocumentBuilder.SpanType.SUPERSCRIPT, false));
    phraseModifierSyntax.add(new SimplePhraseModifier("~", DocumentBuilder.SpanType.SUBSCRIPT, false));
    phraseModifierSyntax.add(new SimpleWrappedPhraseModifier("{{", "}}", DocumentBuilder.SpanType.MONOSPACE, false));
    phraseModifierSyntax.add(new ConfluenceWrappedPhraseModifier("{quote}", DocumentBuilder.SpanType.QUOTE, true));
    phraseModifierSyntax.add(new ColorPhraseModifier());
    phraseModifierSyntax.add(new ImagePhraseModifier());
    phraseModifierSyntax.endGroup(")(?=\\W|$)", 0);
  }
  
  protected void addStandardTokens(MarkupLanguage.PatternBasedSyntax tokenSyntax)
  {
    tokenSyntax.add(new PatternLineBreakReplacementToken("(\\\\\\\\)"));
    tokenSyntax.add(new EscapedCharacterReplacementToken());
    tokenSyntax.add(new EntityReferenceReplacementToken("(tm)", "#8482"));
    tokenSyntax.add(new EntityReferenceReplacementToken("(TM)", "#8482"));
    tokenSyntax.add(new EntityReferenceReplacementToken("(c)", "#169"));
    tokenSyntax.add(new EntityReferenceReplacementToken("(C)", "#169"));
    tokenSyntax.add(new EntityReferenceReplacementToken("(r)", "#174"));
    tokenSyntax.add(new EntityReferenceReplacementToken("(R)", "#174"));
    tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=(?:\\w\\s)|^)(---)(?=\\s\\w))", "#8212"));
    tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=(?:\\w\\s)|^)(--)(?=\\s\\w))", "#8211"));
    tokenSyntax.add(new PatternLiteralReplacementToken("(----)", "<hr/>"));
    tokenSyntax.add(new ImpliedHyperlinkReplacementToken());
    tokenSyntax.add(new AnchorReplacementToken());
  }
  
  protected Block createParagraphBlock()
  {
    return new ParagraphBlock();
  }
  
  public DocumentBuilder createDocumentBuilder(Writer out)
  {
    return new ConfluenceDocumentBuilder(out);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.util;

public abstract interface Options$Handler
{
  public abstract void setOption(String paramString1, String paramString2);
  
  public abstract void setOption(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.util.Options.Handler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.util;

public class Options
{
  public static void parseOptions(String options, Handler handler)
  {
    if (options == null) {
      return;
    }
    String[] opts = options.split("\\s*\\|\\s*");
    String[] arrayOfString1;
    int j = (arrayOfString1 = opts).length;
    for (int i = 0; i < j; i++)
    {
      String optionPair = arrayOfString1[i];
      String[] keyValue = optionPair.split("\\s*=\\s*");
      if (keyValue.length == 2)
      {
        String key = keyValue[0].trim();
        String value = keyValue[1].trim();
        handler.setOption(key, value);
      }
      else if (keyValue.length == 1)
      {
        handler.setOption(optionPair);
      }
    }
  }
  
  public static abstract interface Handler
  {
    public abstract void setOption(String paramString1, String paramString2);
    
    public abstract void setOption(String paramString);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.util.Options
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;

public class ExtendedPreformattedBlock
  extends AbstractConfluenceDelimitedBlock
{
  public ExtendedPreformattedBlock()
  {
    super("noformat");
  }
  
  protected void beginBlock()
  {
    Attributes attributes = new Attributes();
    builder.beginBlock(DocumentBuilder.BlockType.PREFORMATTED, attributes);
  }
  
  protected void endBlock()
  {
    builder.endBlock();
  }
  
  protected void handleBlockContent(String content)
  {
    if (content.length() > 0) {
      builder.characters(content);
    } else if (blockLineCount == 1) {
      return;
    }
    builder.characters("\n");
  }
  
  protected void setOption(String key, String value) {}
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedPreformattedBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;

class ListBlock$ListState
{
  int level;
  DocumentBuilder.BlockType type;
  boolean openItem;
  
  private ListBlock$ListState(int level, DocumentBuilder.BlockType type)
  {
    this.level = level;
    this.type = type;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ListBlock.ListState
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class ListBlock
  extends Block
{
  private static final int LINE_REMAINDER_GROUP_OFFSET = 2;
  static final Pattern startPattern = Pattern.compile("((?:(?:\\*)|(?:#)|(?:-))+)\\s(.*+)");
  private int blockLineCount = 0;
  private Matcher matcher;
  private Stack<ListState> listState;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      this.listState = new Stack();
      Attributes attributes = new Attributes();
      String listSpec = this.matcher.group(1);
      int level = calculateLevel(listSpec);
      DocumentBuilder.BlockType type = calculateType(listSpec);
      if ((type == DocumentBuilder.BlockType.BULLETED_LIST) && ("-".equals(listSpec))) {
        attributes.setCssStyle("list-style: square");
      }
      offset = this.matcher.start(2);
      
      this.listState.push(new ListState(1, type, null));
      builder.beginBlock(type, attributes);
      
      adjustLevel(listSpec, level, type);
    }
    else
    {
      Matcher matcher = startPattern.matcher(line);
      if (!matcher.matches())
      {
        setClosed(true);
        return 0;
      }
      String listSpec = matcher.group(1);
      int level = calculateLevel(listSpec);
      DocumentBuilder.BlockType type = calculateType(listSpec);
      
      offset = matcher.start(2);
      
      adjustLevel(listSpec, level, type);
    }
    blockLineCount += 1;
    
    ListState listState = (ListState)this.listState.peek();
    if (openItem) {
      builder.endBlock();
    }
    openItem = true;
    builder.beginBlock(DocumentBuilder.BlockType.LIST_ITEM, new Attributes());
    
    markupLanguage.emitMarkupLine(getParser(), state, line, offset);
    
    return -1;
  }
  
  private void adjustLevel(String listSpec, int level, DocumentBuilder.BlockType type)
  {
    for (ListState previousState = (ListState)listState.peek(); (level != level) || (type != type); previousState = (ListState)listState.peek()) {
      if (level > level)
      {
        if (!openItem)
        {
          builder.beginBlock(DocumentBuilder.BlockType.LIST_ITEM, new Attributes());
          openItem = true;
        }
        Attributes blockAttributes = new Attributes();
        if ((type == DocumentBuilder.BlockType.BULLETED_LIST) && ("-".equals(listSpec))) {
          blockAttributes.setCssStyle("list-style: square");
        }
        listState.push(new ListState(level + 1, type, null));
        builder.beginBlock(type, blockAttributes);
      }
      else
      {
        closeOne();
        if (listState.isEmpty())
        {
          Attributes blockAttributes = new Attributes();
          if ((type == DocumentBuilder.BlockType.BULLETED_LIST) && ("-".equals(listSpec))) {
            blockAttributes.setCssStyle("list-style: square");
          }
          listState.push(new ListState(1, type, null));
          builder.beginBlock(type, blockAttributes);
        }
      }
    }
  }
  
  private int calculateLevel(String listSpec)
  {
    return listSpec.length();
  }
  
  private DocumentBuilder.BlockType calculateType(String listSpec)
  {
    return listSpec.charAt(listSpec.length() - 1) == '#' ? DocumentBuilder.BlockType.NUMERIC_LIST : DocumentBuilder.BlockType.BULLETED_LIST;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    blockLineCount = 0;
    listState = null;
    if (lineOffset == 0)
    {
      matcher = startPattern.matcher(line);
      boolean matches = matcher.matches();
      if (matches)
      {
        String listSpec = matcher.group(1);
        if (listSpec.charAt(0) == '-')
        {
          int level = calculateLevel(listSpec);
          if (level > 1) {
            return false;
          }
        }
      }
      return matches;
    }
    matcher = null;
    return false;
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed()))
    {
      while ((listState != null) && (!listState.isEmpty())) {
        closeOne();
      }
      listState = null;
    }
    super.setClosed(closed);
  }
  
  private void closeOne()
  {
    ListState e = (ListState)listState.pop();
    if (openItem) {
      builder.endBlock();
    }
    builder.endBlock();
  }
  
  private static class ListState
  {
    int level;
    DocumentBuilder.BlockType type;
    boolean openItem;
    
    private ListState(int level, DocumentBuilder.BlockType type)
    {
      this.level = level;
      this.type = type;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ListBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.IdGenerator;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.ContentState;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class HeadingBlock
  extends Block
{
  static final Pattern startPattern = Pattern.compile("\\s*h([1-6])\\.\\s+(.*)");
  private int blockLineCount = 0;
  private int level = -1;
  private Matcher matcher;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      Attributes attributes = new Attributes();
      
      level = Integer.parseInt(matcher.group(1));
      offset = matcher.start(2);
      if (attributes.getId() == null) {
        attributes.setId(state.getIdGenerator().newId("h" + level, line.substring(offset)));
      }
      builder.beginHeading(level, attributes);
    }
    if ((blockLineCount != 0) || (markupLanguage.isEmptyLine(line)))
    {
      setClosed(true);
      return 0;
    }
    blockLineCount += 1;
    
    getMarkupLanguage().emitMarkupLine(getParser(), state, line, offset);
    
    return -1;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    blockLineCount = 0;
    if (lineOffset == 0)
    {
      matcher = startPattern.matcher(line);
      return matcher.matches();
    }
    matcher = null;
    return false;
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed())) {
      builder.endHeading();
    }
    super.setClosed(closed);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.HeadingBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class TableBlock
  extends Block
{
  static final Pattern startPattern = Pattern.compile("(\\|(.*)?(\\|\\s*$))");
  static final Pattern TABLE_ROW_PATTERN = Pattern.compile("\\|(\\|)?((?:(?:[^\\|\\[]*)(?:\\[[^\\]]*\\])?)*)(\\|\\|?\\s*$)?");
  private int blockLineCount = 0;
  private Matcher matcher;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      Attributes attributes = new Attributes();
      builder.beginBlock(DocumentBuilder.BlockType.TABLE, attributes);
    }
    else if (markupLanguage.isEmptyLine(line))
    {
      setClosed(true);
      return 0;
    }
    blockLineCount += 1;
    if (offset == line.length()) {
      return -1;
    }
    String textileLine = offset == 0 ? line : line.substring(offset);
    Matcher rowMatcher = TABLE_ROW_PATTERN.matcher(textileLine);
    if (!rowMatcher.find())
    {
      setClosed(true);
      return 0;
    }
    builder.beginBlock(DocumentBuilder.BlockType.TABLE_ROW, new Attributes());
    do
    {
      int start = rowMatcher.start();
      if (start == textileLine.length() - 1) {
        break;
      }
      String headerIndicator = rowMatcher.group(1);
      String text = rowMatcher.group(2);
      int lineOffset = offset + rowMatcher.start(2);
      
      boolean header = (headerIndicator != null) && ("|".equals(headerIndicator));
      
      Attributes attributes = new Attributes();
      builder.beginBlock(header ? DocumentBuilder.BlockType.TABLE_CELL_HEADER : DocumentBuilder.BlockType.TABLE_CELL_NORMAL, attributes);
      
      markupLanguage.emitMarkupLine(getParser(), state, lineOffset, text, 0);
      
      builder.endBlock();
    } while (
    
      rowMatcher.find());
    builder.endBlock();
    
    return -1;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    blockLineCount = 0;
    if (lineOffset == 0)
    {
      matcher = startPattern.matcher(line);
      return matcher.matches();
    }
    matcher = null;
    return false;
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed())) {
      builder.endBlock();
    }
    super.setClosed(closed);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.TableBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class ParagraphBlock
  extends Block
{
  private static final Pattern confluenceBlockStart = Pattern.compile("\\{(code|info|tip|warning|panel|note|toc|noformat)(?:(:[^\\}]*))?\\}");
  private int blockLineCount = 0;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      Attributes attributes = new Attributes();
      
      builder.beginBlock(DocumentBuilder.BlockType.PARAGRAPH, attributes);
    }
    if (this.markupLanguage.isEmptyLine(line))
    {
      setClosed(true);
      return 0;
    }
    blockLineCount += 1;
    
    ConfluenceLanguage markupLanguage = (ConfluenceLanguage)getMarkupLanguage();
    for (Block block : markupLanguage.getParagraphBreakingBlocks()) {
      if (block.canStart(line, offset))
      {
        setClosed(true);
        return 0;
      }
    }
    Matcher blockStartMatcher = confluenceBlockStart.matcher(line);
    if (offset > 0) {
      blockStartMatcher.region(offset, line.length());
    }
    if (blockStartMatcher.find())
    {
      int end = blockStartMatcher.start();
      if (end > offset) {
        markupLanguage.emitMarkupLine(getParser(), state, offset, line.substring(offset, end), 0);
      }
      setClosed(true);
      return end;
    }
    if (blockLineCount > 1) {
      builder.lineBreak();
    }
    markupLanguage.emitMarkupLine(getParser(), state, line, offset);
    
    return -1;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    blockLineCount = 0;
    return true;
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed())) {
      builder.endBlock();
    }
    super.setClosed(closed);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ParagraphBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;

public class CodeBlock
  extends AbstractConfluenceDelimitedBlock
{
  private String title;
  private String language;
  
  public CodeBlock()
  {
    super("code");
  }
  
  protected void beginBlock()
  {
    if (title != null)
    {
      Attributes attributes = new Attributes();
      attributes.setTitle(title);
      builder.beginBlock(DocumentBuilder.BlockType.PANEL, attributes);
    }
    Attributes attributes = new Attributes();
    Attributes preAttributes = new Attributes();
    if (language != null) {
      attributes.setCssClass(language + " code-" + language);
    }
    builder.beginBlock(DocumentBuilder.BlockType.PREFORMATTED, preAttributes);
    builder.beginBlock(DocumentBuilder.BlockType.CODE, attributes);
  }
  
  protected void handleBlockContent(String content)
  {
    builder.characters(content);
    builder.characters("\n");
  }
  
  protected void endBlock()
  {
    if (title != null) {
      builder.endBlock();
    }
    builder.endBlock();
    builder.endBlock();
  }
  
  protected void resetState()
  {
    super.resetState();
    title = null;
  }
  
  protected void setOption(String key, String value)
  {
    if (key.equals("title")) {
      title = value;
    }
  }
  
  protected void setOption(String option)
  {
    language = option.toLowerCase();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.CodeBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class ExtendedQuoteBlock
  extends AbstractConfluenceDelimitedBlock
{
  private int paraLine = 0;
  private boolean paraOpen = false;
  private Block nestedBlock = null;
  
  public ExtendedQuoteBlock()
  {
    super("quote");
  }
  
  protected void resetState()
  {
    super.resetState();
    paraOpen = false;
    paraLine = 0;
    nestedBlock = null;
  }
  
  protected void beginBlock()
  {
    Attributes attributes = new Attributes();
    builder.beginBlock(DocumentBuilder.BlockType.QUOTE, attributes);
  }
  
  protected void endBlock()
  {
    if (nestedBlock != null)
    {
      nestedBlock.setClosed(true);
      nestedBlock = null;
    }
    if (paraOpen)
    {
      builder.endBlock();
      paraLine = 0;
      paraOpen = false;
    }
    builder.endBlock();
  }
  
  protected void handleBlockContent(String content)
  {
    if (nestedBlock == null)
    {
      ConfluenceLanguage markupLanguage = (ConfluenceLanguage)getMarkupLanguage();
      for (Block block : markupLanguage.getNestedBlocks()) {
        if (block.canStart(content, 0))
        {
          nestedBlock = block.clone();
          nestedBlock.setParser(getParser());
          nestedBlock.setState(getState());
          if (!paraOpen) {
            break;
          }
          builder.endBlock();
          paraOpen = false;
          paraLine = 0;
          
          break;
        }
      }
    }
    if (nestedBlock != null)
    {
      int lineOffset = nestedBlock.processLine(content, 0);
      if (nestedBlock.isClosed()) {
        nestedBlock = null;
      }
      if ((lineOffset < content.length()) && (lineOffset >= 0))
      {
        if (nestedBlock != null) {
          throw new IllegalStateException("if a block does not fully process a line then it must be closed");
        }
        content = content.substring(lineOffset);
      }
      else
      {
        return;
      }
    }
    if ((blockLineCount == 1) && (content.length() == 0)) {
      return;
    }
    if ((blockLineCount > 1) && (paraOpen) && (getMarkupLanguage().isEmptyLine(content)))
    {
      builder.endBlock();
      paraOpen = false;
      paraLine = 0;
      return;
    }
    if (!paraOpen)
    {
      builder.beginBlock(DocumentBuilder.BlockType.PARAGRAPH, new Attributes());
      paraOpen = true;
    }
    if (paraLine != 0) {
      builder.lineBreak();
    }
    paraLine += 1;
    getMarkupLanguage().emitMarkupLine(getParser(), state, content, 0);
  }
  
  protected void setOption(String key, String value) {}
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedQuoteBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;

public class ColorBlock
  extends ParameterizedBlock
{
  private final Pattern startPattern;
  private final Pattern endPattern;
  private final DocumentBuilder.BlockType blockType;
  private int blockLineCount = 0;
  private Matcher matcher;
  private boolean nesting = false;
  private String color;
  
  public ColorBlock()
  {
    blockType = DocumentBuilder.BlockType.DIV;
    startPattern = Pattern.compile("^\\{color(?::([^\\}]*))?\\}(.*)");
    endPattern = Pattern.compile("(\\{color\\})(.*)");
  }
  
  public int processLineContent(String line, int offset)
  {
    int end = line.length();
    if (blockLineCount == 0)
    {
      setOptions(matcher.group(1));
      
      Attributes attributes = new Attributes();
      if (color != null) {
        attributes.setCssStyle(String.format("color: %s;", new Object[] { color }));
      }
      offset = matcher.start(2);
      
      builder.beginBlock(blockType, attributes);
      
      nesting = true;
      end = offset;
    }
    else
    {
      boolean terminating = false;
      
      Matcher endMatcher = endPattern.matcher(line);
      if (offset < end)
      {
        if (offset > 0) {
          endMatcher.region(offset, end);
        }
        if (endMatcher.find())
        {
          terminating = true;
          end = endMatcher.start(2);
        }
        else
        {
          end = offset;
        }
      }
      if (terminating) {
        setClosed(true);
      }
    }
    blockLineCount += 1;
    
    return end == line.length() ? -1 : end;
  }
  
  public boolean beginNesting()
  {
    return nesting;
  }
  
  public int findCloseOffset(String line, int lineOffset)
  {
    Matcher endMatcher = endPattern.matcher(line);
    if (lineOffset != 0) {
      endMatcher.region(lineOffset, line.length());
    }
    if (endMatcher.find()) {
      return endMatcher.start();
    }
    return -1;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    if (lineOffset > 0) {
      return false;
    }
    blockLineCount = 0;
    color = null;
    nesting = false;
    matcher = startPattern.matcher(line);
    if (lineOffset > 0) {
      matcher.region(lineOffset, line.length());
    }
    return matcher.matches();
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed())) {
      builder.endBlock();
    }
    super.setClosed(closed);
  }
  
  protected void setOption(String option)
  {
    color = option;
  }
  
  protected void setOption(String key, String value) {}
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ColorBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.ContentState;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineParser;

public class TableOfContentsBlock
  extends ParameterizedBlock
{
  static final Pattern startPattern = Pattern.compile("\\s*\\{toc(?::([^\\}]+))?\\}\\s*(.+)?");
  private int blockLineNumber = 0;
  private String style = "none";
  private int maxLevel = Integer.MAX_VALUE;
  private Matcher matcher;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineNumber++ > 0)
    {
      setClosed(true);
      return 0;
    }
    if (!getMarkupLanguage().isFilterGenerativeContents())
    {
      String options = matcher.group(1);
      setOptions(options);
      
      OutlineParser outlineParser = new OutlineParser(new ConfluenceLanguage());
      OutlineItem rootItem = outlineParser.parse(state.getMarkupContent());
      emitToc(rootItem);
    }
    setClosed(true);
    return matcher.start(2);
  }
  
  private void emitToc(OutlineItem item)
  {
    if (item.getChildren().isEmpty()) {
      return;
    }
    if (item.getLevel() + 1 > maxLevel) {
      return;
    }
    Attributes nullAttributes = new Attributes();
    
    builder.beginBlock(DocumentBuilder.BlockType.NUMERIC_LIST, new Attributes(null, null, "list-style: " + style + ";", null));
    for (OutlineItem child : item.getChildren())
    {
      builder.beginBlock(DocumentBuilder.BlockType.LIST_ITEM, nullAttributes);
      builder.link('#' + child.getId(), child.getLabel());
      emitToc(child);
      builder.endBlock();
    }
    builder.endBlock();
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    style = "none";
    maxLevel = Integer.MAX_VALUE;
    blockLineNumber = 0;
    
    matcher = startPattern.matcher(line);
    if (lineOffset > 0) {
      matcher.region(lineOffset, line.length());
    }
    if (matcher.matches()) {
      return true;
    }
    matcher = null;
    return false;
  }
  
  public String getStyle()
  {
    return style;
  }
  
  public void setStyle(String style)
  {
    this.style = style;
  }
  
  public int getMaxLevel()
  {
    return maxLevel;
  }
  
  public void setMaxLevel(int maxLevel)
  {
    this.maxLevel = maxLevel;
  }
  
  protected void setOption(String key, String value)
  {
    if (key.equals("style")) {
      setStyle(value);
    } else if (key.equals("maxLevel")) {
      try
      {
        maxLevel = Integer.parseInt(value);
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.TableOfContentsBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class QuoteBlock
  extends Block
{
  static final Pattern startPattern = Pattern.compile("bq\\.\\s+(.*)");
  private int blockLineCount = 0;
  private Matcher matcher;
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      Attributes attributes = new Attributes();
      
      offset = matcher.start(1);
      
      builder.beginBlock(DocumentBuilder.BlockType.QUOTE, attributes);
      builder.beginBlock(DocumentBuilder.BlockType.PARAGRAPH, new Attributes());
    }
    if (markupLanguage.isEmptyLine(line))
    {
      setClosed(true);
      return 0;
    }
    if (blockLineCount != 0) {
      builder.lineBreak();
    }
    blockLineCount += 1;
    
    getMarkupLanguage().emitMarkupLine(getParser(), state, line, offset);
    
    return -1;
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    blockLineCount = 0;
    matcher = startPattern.matcher(line);
    if (lineOffset > 0) {
      matcher.region(lineOffset, line.length());
    }
    return matcher.matches();
  }
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed()))
    {
      builder.endBlock();
      builder.endBlock();
    }
    super.setClosed(closed);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.QuoteBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.markup.ContentState;

public abstract class AbstractConfluenceDelimitedBlock
  extends ParameterizedBlock
{
  private final Pattern startPattern;
  private final Pattern endPattern;
  protected int blockLineCount = 0;
  private Matcher matcher;
  
  public AbstractConfluenceDelimitedBlock(String blockName)
  {
    startPattern = Pattern.compile("\\s*\\{" + blockName + "(?::([^\\}]*))?\\}(.*)");
    endPattern = Pattern.compile("\\s*(\\{" + blockName + "\\})(.*)");
  }
  
  public int processLineContent(String line, int offset)
  {
    if (blockLineCount == 0)
    {
      setOptions(matcher.group(1));
      
      offset = matcher.start(2);
      
      beginBlock();
    }
    int end = line.length();
    int segmentEnd = end;
    boolean terminating = false;
    if (offset < end)
    {
      Matcher endMatcher = endPattern.matcher(line);
      if (blockLineCount == 0) {
        endMatcher.region(offset, end);
      }
      if (endMatcher.find())
      {
        terminating = true;
        end = endMatcher.start(2);
        segmentEnd = endMatcher.start(1);
      }
    }
    if (end < line.length()) {
      state.setLineSegmentEndOffset(end);
    }
    blockLineCount += 1;
    
    String content = line.substring(offset, segmentEnd);
    handleBlockContent(content);
    if (terminating) {
      setClosed(true);
    }
    return end == line.length() ? -1 : end;
  }
  
  protected abstract void handleBlockContent(String paramString);
  
  protected abstract void beginBlock();
  
  protected abstract void endBlock();
  
  public void setClosed(boolean closed)
  {
    if ((closed) && (!isClosed())) {
      endBlock();
    }
    super.setClosed(closed);
  }
  
  public boolean canStart(String line, int lineOffset)
  {
    resetState();
    matcher = startPattern.matcher(line);
    if (lineOffset > 0) {
      matcher.region(lineOffset, line.length());
    }
    return matcher.matches();
  }
  
  protected void resetState()
  {
    blockLineCount = 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.AbstractConfluenceDelimitedBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import org.eclipse.mylyn.internal.wikitext.confluence.core.util.Options;
import org.eclipse.mylyn.internal.wikitext.confluence.core.util.Options.Handler;
import org.eclipse.mylyn.wikitext.core.parser.markup.Block;

public abstract class ParameterizedBlock
  extends Block
{
  public void setOptions(String options)
  {
    if (options == null) {
      return;
    }
    Options.parseOptions(options, new Options.Handler()
    {
      public void setOption(String key, String value)
      {
        ParameterizedBlock.this.setOption(key, value);
      }
      
      public void setOption(String key)
      {
        ParameterizedBlock.this.setOption(key);
      }
    });
  }
  
  protected void setOption(String option) {}
  
  protected abstract void setOption(String paramString1, String paramString2);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.wikitext.confluence.core.block.ParameterizedBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.wikitext.confluence.core.block;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;

public class TextBoxBlock
  extends ParameterizedBlock
{
  private final Pattern startPattern;
  private final Pattern endPattern;
  private final DocumentBuilde
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd