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

ocumentBuilder:endDocument	()V
    //   643: goto +14 -> 657
    //   646: astore 15
    //   648: aload 6
    //   650: aconst_null
    //   651: invokevirtual 370	org/eclipse/mylyn/wikitext/core/parser/DocumentBuilder:setLocator	(Lorg/eclipse/mylyn/wikitext/core/parser/Locator;)V
    //   654: aload 15
    //   656: athrow
    //   657: aload 6
    //   659: aconst_null
    //   660: invokevirtual 370	org/eclipse/mylyn/wikitext/core/parser/DocumentBuilder:setLocator	(Lorg/eclipse/mylyn/wikitext/core/parser/Locator;)V
    //   663: return
    // Line number table:
    //   Java source line #116	-> byte code offset #0
    //   Java source line #117	-> byte code offset #5
    //   Java source line #118	-> byte code offset #9
    //   Java source line #119	-> byte code offset #15
    //   Java source line #120	-> byte code offset #21
    //   Java source line #122	-> byte code offset #38
    //   Java source line #124	-> byte code offset #44
    //   Java source line #126	-> byte code offset #51
    //   Java source line #127	-> byte code offset #55
    //   Java source line #129	-> byte code offset #60
    //   Java source line #130	-> byte code offset #63
    //   Java source line #132	-> byte code offset #66
    //   Java source line #134	-> byte code offset #69
    //   Java source line #135	-> byte code offset #76
    //   Java source line #136	-> byte code offset #79
    //   Java source line #138	-> byte code offset #82
    //   Java source line #139	-> byte code offset #94
    //   Java source line #140	-> byte code offset #104
    //   Java source line #141	-> byte code offset #111
    //   Java source line #142	-> byte code offset #117
    //   Java source line #145	-> byte code offset #127
    //   Java source line #146	-> byte code offset #140
    //   Java source line #147	-> byte code offset #150
    //   Java source line #148	-> byte code offset #161
    //   Java source line #149	-> byte code offset #167
    //   Java source line #150	-> byte code offset #174
    //   Java source line #151	-> byte code offset #184
    //   Java source line #152	-> byte code offset #189
    //   Java source line #154	-> byte code offset #198
    //   Java source line #155	-> byte code offset #215
    //   Java source line #157	-> byte code offset #222
    //   Java source line #158	-> byte code offset #227
    //   Java source line #159	-> byte code offset #233
    //   Java source line #161	-> byte code offset #236
    //   Java source line #162	-> byte code offset #246
    //   Java source line #163	-> byte code offset #250
    //   Java source line #167	-> byte code offset #257
    //   Java source line #168	-> byte code offset #262
    //   Java source line #169	-> byte code offset #275
    //   Java source line #170	-> byte code offset #285
    //   Java source line #171	-> byte code offset #297
    //   Java source line #174	-> byte code offset #301
    //   Java source line #175	-> byte code offset #306
    //   Java source line #176	-> byte code offset #316
    //   Java source line #177	-> byte code offset #321
    //   Java source line #179	-> byte code offset #324
    //   Java source line #180	-> byte code offset #330
    //   Java source line #181	-> byte code offset #337
    //   Java source line #184	-> byte code offset #343
    //   Java source line #185	-> byte code offset #354
    //   Java source line #186	-> byte code offset #362
    //   Java source line #187	-> byte code offset #368
    //   Java source line #188	-> byte code offset #376
    //   Java source line #189	-> byte code offset #381
    //   Java source line #191	-> byte code offset #390
    //   Java source line #192	-> byte code offset #398
    //   Java source line #194	-> byte code offset #401
    //   Java source line #195	-> byte code offset #416
    //   Java source line #196	-> byte code offset #421
    //   Java source line #198	-> byte code offset #425
    //   Java source line #197	-> byte code offset #461
    //   Java source line #196	-> byte code offset #464
    //   Java source line #204	-> byte code offset #468
    //   Java source line #205	-> byte code offset #481
    //   Java source line #206	-> byte code offset #491
    //   Java source line #207	-> byte code offset #498
    //   Java source line #209	-> byte code offset #508
    //   Java source line #210	-> byte code offset #511
    //   Java source line #136	-> byte code offset #518
    //   Java source line #213	-> byte code offset #523
    //   Java source line #214	-> byte code offset #535
    //   Java source line #215	-> byte code offset #545
    //   Java source line #216	-> byte code offset #551
    //   Java source line #218	-> byte code offset #560
    //   Java source line #219	-> byte code offset #562
    //   Java source line #222	-> byte code offset #572
    //   Java source line #223	-> byte code offset #585
    //   Java source line #225	-> byte code offset #591
    //   Java source line #226	-> byte code offset #596
    //   Java source line #227	-> byte code offset #599
    //   Java source line #228	-> byte code offset #609
    //   Java source line #229	-> byte code offset #617
    //   Java source line #226	-> byte code offset #623
    //   Java source line #232	-> byte code offset #631
    //   Java source line #235	-> byte code offset #634
    //   Java source line #236	-> byte code offset #638
    //   Java source line #238	-> byte code offset #646
    //   Java source line #239	-> byte code offset #648
    //   Java source line #240	-> byte code offset #654
    //   Java source line #239	-> byte code offset #657
    //   Java source line #241	-> byte code offset #663
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	664	0	this	MarkupLanguage
    //   0	664	1	parser	MarkupParser
    //   0	664	2	markupContent	String
    //   0	664	3	asDocument	boolean
    //   13	539	4	state	ContentState
    //   36	502	5	reader	org.eclipse.mylyn.wikitext.core.util.LocationTrackingReader
    //   42	616	6	builder	DocumentBuilder
    //   61	572	7	nestedBlocks	Stack<Block>
    //   64	418	8	lineStates	Stack<LineState>
    //   74	445	9	line	String
    //   572	1	9	line	String
    //   67	519	10	currentBlock	Block
    //   77	433	11	lineOffset	int
    //   560	7	11	e	java.io.IOException
    //   607	11	11	block	Block
    //   148	3	12	nestedParent	Block
    //   283	15	12	nestedParent	Block
    //   489	10	12	lineState	LineState
    //   159	88	13	closeOffset	int
    //   182	34	14	truncatedLine	String
    //   646	9	15	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   69	557	560	java/io/IOException
    //   51	646	646	finally
  }
  
  private static class Group
  {
    int count;
  }
  
  private static class LineState
  {
    int lineOffset;
    String line;
    
    public LineState(String line, int offset)
    {
      this.line = line;
      lineOffset = offset;
    }
  }
  
  private void initProcessors()
  {
    for (Block block : getBlocks())
    {
      if (block.getMarkupLanguage() != null) {
        return;
      }
      block.setMarkupLanguage(this);
    }
  }
  
  public Block startBlock(String line, int lineOffset)
  {
    if (isEmptyLine(line)) {
      return null;
    }
    for (Block block : getBlocks()) {
      if (block.canStart(line, lineOffset)) {
        return block.clone();
      }
    }
    return null;
  }
  
  public abstract List<Block> getBlocks();
  
  public void configure(MarkupLanguageConfiguration configuration)
    throws UnsupportedOperationException
  {
    this.configuration = configuration;
    initializeSyntax(true);
  }
  
  private void initializeSyntax(boolean force)
  {
    if ((force) || (!syntaxInitialized))
    {
      syntaxInitialized = true;
      initializeSyntax();
    }
  }
  
  protected abstract void initializeSyntax();
  
  public void emitMarkupLine(MarkupParser parser, ContentState state, int textLineOffset, String line, int offset)
  {
    if (offset == line.length()) {
      return;
    }
    if (blocksOnly)
    {
      emitMarkupText(parser, state, line.substring(offset));
      return;
    }
    int previousShift = state.getShift();
    state.setShift(previousShift + textLineOffset);
    do
    {
      PatternBasedElementProcessor phraseModifier = getPhraseModifierSyntax().findPatternBasedElement(line, 
        offset);
      if (phraseModifier == null) {
        break;
      }
      int newOffset = phraseModifier.getLineStartOffset();
      if (offset < newOffset)
      {
        state.setLineCharacterOffset(state.getShift() + offset);
        state.setLineSegmentEndOffset(state.getShift() + newOffset);
        String text = line.substring(offset, newOffset);
        emitMarkupText(parser, state, text);
      }
      phraseModifier.setMarkupLanguage(this);
      phraseModifier.setParser(parser);
      phraseModifier.setState(state);
      state.setLineCharacterOffset(state.getShift() + phraseModifier.getLineStartOffset());
      state.setLineSegmentEndOffset(state.getShift() + phraseModifier.getLineEndOffset());
      phraseModifier.emit();
      offset = phraseModifier.getLineEndOffset();
    } while (offset < line.length());
    break label228;
    state.setLineCharacterOffset(state.getShift() + offset);
    state.setLineSegmentEndOffset(state.getShift() + line.length());
    emitMarkupText(parser, state, line.substring(offset));
    label228:
    state.setShift(previousShift);
  }
  
  public void emitMarkupLine(MarkupParser parser, ContentState state, String line, int offset)
  {
    emitMarkupLine(parser, state, 0, line, offset);
  }
  
  public void emitMarkupText(MarkupParser parser, ContentState state, String text)
  {
    if (blocksOnly)
    {
      parser.getBuilder().characters(text);
      return;
    }
    int offset = 0;
    do
    {
      PatternBasedElementProcessor tokenReplacement = getReplacementTokenSyntax().findPatternBasedElement(text, 
        offset);
      if (tokenReplacement == null) {
        break;
      }
      int newOffset = tokenReplacement.getLineStartOffset();
      if (offset < newOffset)
      {
        String text2 = text.substring(offset, newOffset);
        emitMarkupText(parser, state, text2);
      }
      tokenReplacement.setMarkupLanguage(this);
      tokenReplacement.setParser(parser);
      tokenReplacement.setState(state);
      
      state.setLineCharacterOffset(state.getShift() + tokenReplacement.getLineStartOffset());
      state.setLineSegmentEndOffset(state.getShift() + tokenReplacement.getLineEndOffset());
      
      tokenReplacement.emit();
      offset = tokenReplacement.getLineEndOffset();
    } while (offset < text.length());
    return;
    
    parser.getBuilder().characters(offset > 0 ? text.substring(offset) : text);
  }
  
  protected abstract PatternBasedSyntax getPhraseModifierSyntax();
  
  protected abstract PatternBasedSyntax getReplacementTokenSyntax();
  
  public static final class PatternBasedSyntax
  {
    protected List<PatternBasedElement> elements = new ArrayList();
    protected Pattern elementPattern;
    protected List<Integer> elementGroup = new ArrayList();
    private final StringBuilder patternBuffer = new StringBuilder();
    private int patternGroup = 0;
    private final Stack<MarkupLanguage.Group> groups = new Stack();
    
    public PatternBasedSyntax()
    {
      groups.push(new MarkupLanguage.Group(null));
    }
    
    public void add(PatternBasedElement element)
    {
      elementPattern = null;
      elements.add(element);
      if (groups.peek()).count++ > 0) {
        patternBuffer.append('|');
      }
      patternGroup += 1;
      patternBuffer.append('(');
      patternBuffer.append(element.getPattern(patternGroup));
      patternBuffer.append(')');
      elementGroup.add(Integer.valueOf(patternGroup));
      patternGroup += element.getPatternGroupCount();
    }
    
    protected List<PatternBasedElement> getElements()
    {
      return Collections.unmodifiableList(elements);
    }
    
    public void beginGroup(String regexFragment, int size)
    {
      add(regexFragment, size, true);
    }
    
    public void endGroup(String regexFragment, int size)
    {
      add(regexFragment, size, false);
    }
    
    private void add(String regexFragment, int size, boolean beginGroup)
    {
      elementPattern = null;
      if (beginGroup)
      {
        if (groups.peek()).count++ > 0) {
          patternBuffer.append('|');
        }
        groups.push(new MarkupLanguage.Group(null));
        patternBuffer.append("(?:");
      }
      else
      {
        groups.pop();
      }
      patternBuffer.append(regexFragment);
      if (!beginGroup) {
        patternBuffer.append(")");
      }
      patternGroup += size;
    }
    
    public PatternBasedElementProcessor findPatternBasedElement(String lineText, int offset)
    {
      Matcher matcher = getPattern().matcher(lineText);
      if (offset > 0) {
        matcher.region(offset, lineText.length());
      }
      if (matcher.find())
      {
        int size = elementGroup.size();
        for (int x = 0; x < size; x++)
        {
          int group = ((Integer)elementGroup.get(x)).intValue();
          String value = matcher.group(group);
          if (value != null)
          {
            PatternBasedElement element = (PatternBasedElement)elements.get(x);
            PatternBasedElementProcessor processor = element.newProcessor();
            processor.setLineStartOffset(matcher.start());
            processor.setLineEndOffset(matcher.end());
            processor.setGroup(0, matcher.group(0), matcher.start(0), matcher.end(0));
            for (int y = 0; y < element.getPatternGroupCount(); y++)
            {
              int groupIndex = group + y + 1;
              processor.setGroup(y + 1, matcher.group(groupIndex), matcher.start(groupIndex), 
                matcher.end(groupIndex));
            }
            return processor;
          }
        }
        throw new IllegalStateException();
      }
      return null;
    }
    
    public Pattern getPattern()
    {
      if (elementPattern == null) {
        if (patternBuffer.length() > 0) {
          elementPattern = Pattern.compile(patternBuffer.toString());
        } else {
          return null;
        }
      }
      return elementPattern;
    }
    
    public void clear()
    {
      elements.clear();
      elementPattern = null;
      elementGroup.clear();
      patternBuffer.delete(0, patternBuffer.length());
      patternGroup = 0;
      groups.clear();
      groups.push(new MarkupLanguage.Group(null));
    }
  }
  
  public String getName()
  {
    return name;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public String getExtendsLanguage()
  {
    return extendsLanguage;
  }
  
  public void setExtendsLanguage(String extendsLanguage)
  {
    this.extendsLanguage = extendsLanguage;
  }
  
  public boolean isFilterGenerativeContents()
  {
    return filterGenerativeBlocks;
  }
  
  public void setFilterGenerativeContents(boolean filterGenerativeBlocks)
  {
    this.filterGenerativeBlocks = filterGenerativeBlocks;
  }
  
  public boolean isBlocksOnly()
  {
    return blocksOnly;
  }
  
  public void setBlocksOnly(boolean blocksOnly)
  {
    this.blocksOnly = blocksOnly;
  }
  
  public boolean isEmptyLine(String line)
  {
    if (line.length() == 0) {
      return true;
    }
    for (int x = 0; x < line.length(); x++) {
      if (!Character.isWhitespace(line.charAt(x))) {
        return false;
      }
    }
    return true;
  }
  
  public String getInternalLinkPattern()
  {
    return internalLinkPattern;
  }
  
  public void setInternalLinkPattern(String internalLinkPattern)
  {
    this.internalLinkPattern = internalLinkPattern;
  }
  
  public boolean isDetectingRawHyperlinks()
  {
    initializeSyntax(false);
    PatternBasedSyntax replacementTokenSyntax = getReplacementTokenSyntax();
    if (replacementTokenSyntax != null) {
      for (PatternBasedElement element : replacementTokenSyntax.getElements()) {
        if ((element instanceof ImpliedHyperlinkReplacementToken)) {
          return true;
        }
      }
    }
    return false;
  }
  
  public boolean isEnableMacros()
  {
    return enableMacros;
  }
  
  public void setEnableMacros(boolean enableMacros)
  {
    this.enableMacros = enableMacros;
  }
  
  public DocumentBuilder createDocumentBuilder(Writer out)
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser;

public class ListAttributes
  extends Attributes
{
  private String start;
  
  public String getStart()
  {
    return start;
  }
  
  public void setStart(String start)
  {
    this.start = start;
  }
}

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

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.mylyn.wikitext.core.parser.markup.DefaultIdGenerationStrategy;
import org.eclipse.mylyn.wikitext.core.parser.markup.IdGenerationStrategy;

public class IdGenerator
{
  private static final DefaultIdGenerationStrategy DEFAULT_ID_GENERATION_STRATEGY = new DefaultIdGenerationStrategy();
  private final Map<String, Integer> idGenerators = new HashMap();
  private final Set<String> anchorNames = new HashSet();
  private IdGenerationStrategy generationStrategy = DEFAULT_ID_GENERATION_STRATEGY;
  
  public boolean reserveId(String id)
  {
    return anchorNames.add(id);
  }
  
  public String newId(String type, String text)
  {
    if (type == null) {
      type = "";
    }
    Integer current = (Integer)idGenerators.get(type);
    if (current == null) {
      current = Integer.valueOf(0);
    }
    current = Integer.valueOf(current.intValue() + 1);
    
    idGenerators.put(type, current);
    
    String id = null;
    if (text != null)
    {
      id = generationStrategy.generateId(text.trim());
      if ((id == null) || (id.length() == 0)) {
        id = type + '-' + current;
      }
    }
    else
    {
      id = type + '-' + current;
    }
    String template = id;
    int suffix = 1;
    while (!anchorNames.add(id)) {
      id = template + ++suffix;
    }
    return id;
  }
  
  public Set<String> getAnchorNames()
  {
    return Collections.unmodifiableSet(anchorNames);
  }
  
  public IdGenerationStrategy getGenerationStrategy()
  {
    return generationStrategy;
  }
  
  public void setGenerationStrategy(IdGenerationStrategy generationStrategy)
  {
    if (generationStrategy == null) {
      throw new IllegalArgumentException();
    }
    this.generationStrategy = generationStrategy;
  }
}

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

public enum DocumentBuilder$BlockType
{
  PARAGRAPH,  TIP,  WARNING,  INFORMATION,  NOTE,  PANEL,  DIV,  FOOTNOTE,  QUOTE,  CODE,  PREFORMATTED,  NUMERIC_LIST,  BULLETED_LIST,  LIST_ITEM,  TABLE,  TABLE_ROW,  TABLE_CELL_HEADER,  TABLE_CELL_NORMAL,  DEFINITION_LIST,  DEFINITION_TERM,  DEFINITION_ITEM;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser;

public class TableRowAttributes
  extends Attributes
{
  private String bgcolor;
  private String align;
  private String valign;
  
  public String getBgcolor()
  {
    return bgcolor;
  }
  
  public void setBgcolor(String bgcolor)
  {
    this.bgcolor = bgcolor;
  }
  
  public String getAlign()
  {
    return align;
  }
  
  public void setAlign(String align)
  {
    this.align = align;
  }
  
  public String getValign()
  {
    return valign;
  }
  
  public void setValign(String valign)
  {
    this.valign = valign;
  }
}

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

public class TableAttributes
  extends Attributes
{
  private String border;
  private String summary;
  private String width;
  private String frame;
  private String rules;
  private String cellspacing;
  private String cellpadding;
  private String bgcolor;
  
  public String getBorder()
  {
    return border;
  }
  
  public void setBorder(String border)
  {
    this.border = border;
  }
  
  public String getSummary()
  {
    return summary;
  }
  
  public void setSummary(String summary)
  {
    this.summary = summary;
  }
  
  public String getWidth()
  {
    return width;
  }
  
  public void setWidth(String width)
  {
    this.width = width;
  }
  
  public String getFrame()
  {
    return frame;
  }
  
  public void setFrame(String frame)
  {
    this.frame = frame;
  }
  
  public String getRules()
  {
    return rules;
  }
  
  public void setRules(String rules)
  {
    this.rules = rules;
  }
  
  public String getCellspacing()
  {
    return cellspacing;
  }
  
  public void setCellspacing(String cellspacing)
  {
    this.cellspacing = cellspacing;
  }
  
  public String getCellpadding()
  {
    return cellpadding;
  }
  
  public void setCellpadding(String cellpadding)
  {
    this.cellpadding = cellpadding;
  }
  
  public String getBgcolor()
  {
    return bgcolor;
  }
  
  public void setBgcolor(String bgcolor)
  {
    this.bgcolor = bgcolor;
  }
}

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

public enum ImageAttributes$Align
{
  Left,  Right,  Top,  Texttop,  Middle,  Absmiddle,  Baseline,  Bottom,  Absbottom,  Center;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.ImageAttributes.Align
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser;

import java.io.IOException;
import org.eclipse.mylyn.internal.wikitext.core.parser.html.AbstractSaxHtmlParser;
import org.eclipse.mylyn.internal.wikitext.core.parser.html.XHtmlParser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class HtmlParser
{
  public void parse(InputSource input, DocumentBuilder builder)
    throws IOException, SAXException
  {
    if (input == null) {
      throw new IllegalArgumentException();
    }
    if (builder == null) {
      throw new IllegalArgumentException();
    }
    AbstractSaxHtmlParser parser;
    AbstractSaxHtmlParser parser;
    if (isJsoupAvailable()) {
      parser = new org.eclipse.mylyn.internal.wikitext.core.parser.html.HtmlParser();
    } else {
      parser = new XHtmlParser();
    }
    parser.parse(input, builder);
  }
  
  private boolean isJsoupAvailable()
  {
    try
    {
      Class.forName("org.jsoup.Jsoup", true, HtmlParser.class.getClassLoader());
      return true;
    }
    catch (Throwable localThrowable) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.HtmlParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

import java.util.Map;

class OutlineItem$1
  implements OutlineItem.Visitor
{
  OutlineItem$1(OutlineItem paramOutlineItem) {}
  
  public boolean visit(OutlineItem item)
  {
    if (item.getId() != null) {
      OutlineItem.access$0(this$0).put(item.getId(), item);
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

class OutlineItem$2
  implements OutlineItem.Visitor
{
  OutlineItem$2(OutlineItem paramOutlineItem) {}
  
  public boolean visit(OutlineItem item)
  {
    OutlineItem.access$1(item, -1);
    OutlineItem.access$2(item, null);
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

abstract interface package-info {}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.package-info
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

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.DocumentBuilder.SpanType;
import org.eclipse.mylyn.wikitext.core.parser.HeadingAttributes;
import org.eclipse.mylyn.wikitext.core.parser.IdGenerator;
import org.eclipse.mylyn.wikitext.core.parser.Locator;

public class OutlineParser$OutlineBuilder
  extends DocumentBuilder
{
  private OutlineItem currentItem;
  private int level;
  private StringBuilder buf;
  protected final IdGenerator idGenerator = new IdGenerator();
  private int offset;
  private int length;
  private final OutlineItem rootItem;
  private final int labelMaxLength;
  private Attributes attributes;
  
  public OutlineParser$OutlineBuilder(OutlineParser paramOutlineParser, OutlineItem root, int labelMaxLength)
  {
    currentItem = root;
    rootItem = root;
    this.labelMaxLength = labelMaxLength;
  }
  
  public void acronym(String text, String definition) {}
  
  public void beginBlock(DocumentBuilder.BlockType type, Attributes attributes)
  {
    registerId(attributes.getId());
  }
  
  public void beginDocument()
  {
    rootItem.clear();
    currentItem = rootItem;
  }
  
  public void beginHeading(int level, Attributes attributes)
  {
    this.level = level;
    this.attributes = attributes;
    buf = new StringBuilder();
    offset = getLocator().getDocumentOffset();
    length = getLocator().getLineLength();
  }
  
  public void beginSpan(DocumentBuilder.SpanType type, Attributes attributes)
  {
    registerId(attributes.getId());
  }
  
  public void characters(String text)
  {
    if (buf != null) {
      buf.append(text);
    }
  }
  
  public void charactersUnescaped(String literal)
  {
    if (buf != null) {
      buf.append(literal);
    }
  }
  
  public void endBlock() {}
  
  public void endDocument() {}
  
  public void endHeading()
  {
    boolean includeInToc = true;
    if ((attributes instanceof HeadingAttributes))
    {
      HeadingAttributes headingAttributes = (HeadingAttributes)attributes;
      if (headingAttributes.isOmitFromTableOfContents()) {
        includeInToc = false;
      }
    }
    if (includeInToc)
    {
      String label = buf.toString();
      String fullLabelText = label;
      if (label == null) {
        label = "";
      } else if ((labelMaxLength > 0) && (label.length() > labelMaxLength)) {
        label = label.substring(0, labelMaxLength) + "...";
      }
      String kind = "h" + level;
      while (level <= currentItem.getLevel()) {
        currentItem = currentItem.getParent();
      }
      String id = attributes.getId();
      if (id != null) {
        idGenerator.reserveId(id);
      } else {
        id = idGenerator.newId(kind, fullLabelText);
      }
      currentItem = this$0.createOutlineItem(currentItem, level, id, offset, length, label);
      currentItem.setTooltip(fullLabelText);
      currentItem.setKind(kind);
    }
    else
    {
      registerId(attributes.getId());
    }
    buf = null;
    offset = 0;
    length = 0;
    attributes = null;
  }
  
  public void endSpan() {}
  
  public void entityReference(String entity) {}
  
  public void image(Attributes attributes, String url)
  {
    registerId(attributes.getId());
  }
  
  public void imageLink(Attributes linkAttributes, Attributes imageAttributes, String href, String imageUrl)
  {
    registerId(linkAttributes.getId());
    registerId(imageAttributes.getId());
  }
  
  public void lineBreak() {}
  
  public void link(Attributes attributes, String hrefOrHashName, String text)
  {
    registerId(attributes.getId());
    if (buf != null) {
      buf.append(text);
    }
  }
  
  private void registerId(String id)
  {
    idGenerator.reserveId(id);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineParser.OutlineBuilder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

public abstract interface OutlineItem$Visitor
{
  public abstract boolean visit(OutlineItem paramOutlineItem);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.Visitor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class OutlineItem
{
  private OutlineItem parent;
  private final int level;
  private List<OutlineItem> children = new ArrayList();
  private final int offset;
  private int length;
  private final String id;
  private String label;
  private String kind;
  private int childOffset;
  private String tooltip;
  private Map<String, OutlineItem> itemsById;
  private String resourcePath;
  private int hash = -1;
  private String positionKey;
  
  public OutlineItem(OutlineItem parent, int level, String id, int offset, int length, String label)
  {
    this.parent = parent;
    this.level = (parent == null ? 0 : level);
    if ((parent != null) && (level < parent.getLevel())) {
      throw new IllegalArgumentException();
    }
    this.id = id;
    this.offset = offset;
    this.length = length;
    this.label = label;
    if (parent != null) {
      parent.addChild(this);
    }
  }
  
  public int getLength()
  {
    return length;
  }
  
  public int getSectionLength()
  {
    if (parent == null) {
      return length;
    }
    List<OutlineItem> siblings = getParent().getChildren();
    int index = siblings.indexOf(this);
    if (index < siblings.size() - 1) {
      return ((OutlineItem)siblings.get(index + 1)).getOffset() - getOffset();
    }
    int parentRelativeOffset = getOffset() - parent.getOffset();
    return parent.getSectionLength() - parentRelativeOffset;
  }
  
  public String getKind()
  {
    return kind;
  }
  
  public void setKind(String kind)
  {
    this.kind = kind;
  }
  
  public String getLabel()
  {
    return label;
  }
  
  public String getId()
  {
    return id;
  }
  
  public int getLevel()
  {
    if (parent == null) {
      return 0;
    }
    return level;
  }
  
  void setLength(int length)
  {
    this.length = length;
  }
  
  public void setLabel(String label)
  {
    this.label = label;
  }
  
  public OutlineItem getParent()
  {
    return parent;
  }
  
  public boolean isRootItem()
  {
    return parent == null;
  }
  
  public OutlineItem getPrevious()
  {
    if (parent == null) {
      return null;
    }
    List<OutlineItem> siblings = parent.getChildren();
    int index = siblings.indexOf(this);
    if (index > 0) {
      return (OutlineItem)siblings.get(index - 1);
    }
    return parent;
  }
  
  public List<OutlineItem> getChildren()
  {
    return children;
  }
  
  public int getOffset()
  {
    return offset;
  }
  
  public int hashCode()
  {
    if (hash == -1) {
      hash = calculatePositionKey().hashCode();
    }
    return hash;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    OutlineItem other = (OutlineItem)obj;
    
    boolean isEqual = (other.hashCode() == hashCode()) && (other.calculatePositionKey().equals(calculatePositionKey()));
    if (isEqual)
    {
      OutlineItem thisRoot = computeRoot(this);
      OutlineItem otherRoot = computeRoot(other);
      if ((thisRoot != otherRoot) && (thisRoot.getResourcePath() != otherRoot.getResourcePath()) && (
        (thisRoot.getResourcePath() == null) || 
        (!thisRoot.getResourcePath().equals(otherRoot.getResourcePath())))) {
        isEqual = false;
      }
    }
    return isEqual;
  }
  
  private OutlineItem computeRoot(OutlineItem item)
  {
    while (!item.isRootItem()) {
      item = item.getParent();
    }
    return item;
  }
  
  public void clear()
  {
    children.clear();
  }
  
  private String calculatePositionKey()
  {
    if (positionKey == null) {
      if (parent == null) {
        positionKey = "";
      } else {
        positionKey = (getParent().calculatePositionKey() + "/" + kind + childOffset);
      }
    }
    return positionKey;
  }
  
  private void addChild(OutlineItem outlineItem)
  {
    childOffset = children.size();
    children.add(outlineItem);
  }
  
  public OutlineItem findNearestMatchingOffset(int offset)
  {
    NearestItemVisitor visitor = new NearestItemVisitor(offset);
    accept(visitor);
    
    return nearest;
  }
  
  public OutlineItem findItemById(String id)
  {
    if (itemsById == null)
    {
      itemsById = new HashMap();
      accept(new Visitor()
      {
        public boolean visit(OutlineItem item)
        {
          if (item.getId() != null) {
            itemsById.put(item.getId(), item);
          }
          return true;
        }
      });
    }
    return (OutlineItem)itemsById.get(id);
  }
  
  private static class NearestItemVisitor
    implements OutlineItem.Visitor
  {
    private OutlineItem nearest = null;
    private final int offset;
    
    public NearestItemVisitor(int offset)
    {
      this.offset = offset;
    }
    
    public boolean visit(OutlineItem item)
    {
      if (item.isRootItem()) {
        return true;
      }
      if (nearest == null)
      {
        nearest = item;
        return true;
      }
      int itemDistance = item.distance(offset);
      if (itemDistance > 0) {
        return true;
      }
      int nearestDistance = nearest.distance(offset);
      nearestDistance = Math.abs(nearestDistance);
      itemDistance = Math.abs(itemDistance);
      if (itemDistance < nearestDistance) {
        nearest = item;
      } else if (itemDistance > nearestDistance) {
        return false;
      }
      return true;
    }
  }
  
  public int distance(int offset)
  {
    int startDistance = this.offset - offset;
    
    return startDistance;
  }
  
  public void accept(Visitor visitor)
  {
    if (visitor.visit(this)) {
      for (OutlineItem item : getChildren()) {
        item.accept(visitor);
      }
    }
  }
  
  public void setTooltip(String tooltip)
  {
    this.tooltip = tooltip;
  }
  
  public String getTooltip()
  {
    return tooltip;
  }
  
  public String getResourcePath()
  {
    if (getParent() != null) {
      return getParent().getResourcePath();
    }
    return resourcePath;
  }
  
  public void setResourcePath(String resourcePath)
  {
    if (getParent() != null) {
      getParent().setResourcePath(resourcePath);
    } else {
      this.resourcePath = resourcePath;
    }
  }
  
  public void moveChildren(OutlineItem otherParent)
  {
    if (!children.isEmpty())
    {
      Iterator localIterator;
      OutlineItem child;
      if (children.isEmpty())
      {
        List<OutlineItem> temp = children;
        children = children;
        children = temp;
        for (localIterator = children.iterator(); localIterator.hasNext();)
        {
          child = (OutlineItem)localIterator.next();
          parent = this;
        }
      }
      else
      {
        children.addAll(children);
        for (OutlineItem child : children) {
          parent = this;
        }
        children.clear();
      }
      Visitor visitor = new Visitor()
      {
        public boolean visit(OutlineItem item)
        {
          hash = -1;
          positionKey = null;
          return true;
        }
      };
      for (OutlineItem child : children) {
        child.accept(visitor);
      }
    }
    else
    {
      children.clear();
    }
    itemsById = null;
    setLength(otherParent.getLength());
  }
  
  public boolean contains(OutlineItem item)
  {
    if ((item == this) || (isRootItem())) {
      return true;
    }
    if (getOffset() <= item.getOffset())
    {
      int end = getOffset() + getSectionLength();
      int itemEnd = item.getOffset() + item.getSectionLength();
      if (end >= itemEnd) {
        return true;
      }
    }
    return false;
  }
  
  public String toString()
  {
    return "OutlineItem(" + calculatePositionKey() + "/" + getId() + "/" + System.identityHashCode(this) + ")";
  }
  
  public static abstract interface Visitor
  {
    public abstract boolean visit(OutlineItem paramOutlineItem);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

class OutlineItem$NearestItemVisitor
  implements OutlineItem.Visitor
{
  private OutlineItem nearest = null;
  private final int offset;
  
  public OutlineItem$NearestItemVisitor(int offset)
  {
    this.offset = offset;
  }
  
  public boolean visit(OutlineItem item)
  {
    if (item.isRootItem()) {
      return true;
    }
    if (nearest == null)
    {
      nearest = item;
      return true;
    }
    int itemDistance = item.distance(offset);
    if (itemDistance > 0) {
      return true;
    }
    int nearestDistance = nearest.distance(offset);
    nearestDistance = Math.abs(nearestDistance);
    itemDistance = Math.abs(itemDistance);
    if (itemDistance < nearestDistance) {
      nearest = item;
    } else if (itemDistance > nearestDistance) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.NearestItemVisitor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.wikitext.core.parser.outline;

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.DocumentBuilder.SpanType;
import org.eclipse.mylyn.wikitext.core.parser.HeadingAttributes;
import org.eclipse.mylyn.wikitext.core.parser.IdGenerator;
import org.eclipse.mylyn.wikitext.core.parser.Locator;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;

public class OutlineParser
{
  private int labelMaxLength = 0;
  private MarkupLanguage markupLanguage;
  
  public OutlineParser(MarkupLanguage markupLanguage)
  {
    this.markupLanguage = markupLanguage;
  }
  
  public OutlineParser() {}
  
  public int getLabelMaxLength()
  {
    return labelMaxLength;
  }
  
  public void setLabelMaxLength(int labelMaxLength)
  {
    this.labelMaxLength = labelMaxLength;
  }
  
  public OutlineItem parse(String markup)
  {
    OutlineItem root = createRootItem();
    
    return parse(root, markup);
  }
  
  public MarkupLanguage getMarkupLanguage()
  {
    return markupLanguage;
  }
  
  public void setMarkupLanguage(MarkupLanguage markupLanguage)
  {
    this.markupLanguage = markupLanguage;
  }
  
  public OutlineItem createRootItem()
  {
    return createOutlineItem(null, 0, "<root>", 0, 0, "<root>");
  }
  
  /* Error */
  public OutlineItem parse(OutlineItem root, String markup)
  {
    //
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

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-2019. Infinite Loop Ltd