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

  while ((st < len) && (text.charAt(st) <= ' ')) {
      st++;
    }
    return st > 0 ? text.substring(st, len) : text;
  }
  
  protected abstract void parse(InputSource paramInputSource, DocumentBuilder paramDocumentBuilder, ContentHandler paramContentHandler)
    throws IOException, SAXException;
  
  public void parse(InputSource input, DocumentBuilder builder)
    throws IOException, SAXException
  {
    parse(input, builder, createContentHandler(builder));
  }
  
  protected ContentHandler createContentHandler(DocumentBuilder builder)
  {
    return new DocumentBuilderAdapter(builder);
  }
}

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

import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.xml.sax.Attributes;

class AbstractSaxHtmlParser$DocumentBuilderAdapter$HeadingElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  int level;
  
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$HeadingElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter, int level)
  {
    super(paramDocumentBuilderAdapter, null);
    this.level = level;
  }
  
  void start(Attributes atts)
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).beginHeading(level, AbstractSaxHtmlParser.access$2(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), atts));
  }
  
  void end()
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).endHeading();
  }
}

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

import org.eclipse.mylyn.wikitext.core.util.FormattingXMLStreamWriter;
import org.eclipse.mylyn.wikitext.core.util.XmlStreamWriter;

class DitaTopicDocumentBuilder$1
  extends FormattingXMLStreamWriter
{
  DitaTopicDocumentBuilder$1(XmlStreamWriter $anonymous0)
  {
    super($anonymous0);
  }
  
  protected boolean preserveWhitespace(String elementName)
  {
    return (elementName.equals("codeblock")) || (elementName.startsWith("pre"));
  }
}

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

import java.util.List;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineParser;

public class SplittingOutlineParser
  extends OutlineParser
{
  private SplittingStrategy splittingStrategy;
  
  protected OutlineItem createOutlineItem(OutlineItem current, int level, String id, int offset, int length, String label)
  {
    if (splittingStrategy == null) {
      throw new IllegalStateException();
    }
    splittingStrategy.heading(level, id, label);
    SplitOutlineItem outlineItem = new SplitOutlineItem(current, level, id, offset, length, label);
    if (splittingStrategy.isSplit()) {
      outlineItem.setSplitTarget(splittingStrategy.getSplitTarget());
    }
    return outlineItem;
  }
  
  public SplittingStrategy getSplittingStrategy()
  {
    return splittingStrategy;
  }
  
  public void setSplittingStrategy(SplittingStrategy splittingStrategy)
  {
    this.splittingStrategy = splittingStrategy;
  }
  
  public SplitOutlineItem parse(String markup)
  {
    SplitOutlineItem rootItem = (SplitOutlineItem)super.parse(markup);
    if (!rootItem.getChildren().isEmpty())
    {
      SplitOutlineItem firstChild = (SplitOutlineItem)rootItem.getChildren().get(0);
      if ((firstChild.getSplitTarget() == null) || (firstChild.getSplitTarget().equals(rootItem.getSplitTarget()))) {
        rootItem.setLabel(firstChild.getLabel());
      } else {
        rootItem.setLabel("");
      }
    }
    return rootItem;
  }
}

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

import org.xml.sax.Attributes;

class AbstractSaxHtmlParser$DocumentBuilderAdapter$ContentElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$ContentElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter)
  {
    super(paramDocumentBuilderAdapter, null);
  }
  
  public void start(Attributes atts) {}
  
  public void end() {}
}

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

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

class AbstractSaxHtmlParser$DocumentBuilderAdapter$BlockElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  private final DocumentBuilder.BlockType blockType;
  
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$BlockElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter, DocumentBuilder.BlockType blockType)
  {
    super(paramDocumentBuilderAdapter, null);
    this.blockType = blockType;
  }
  
  public void start(Attributes atts)
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).beginBlock(blockType, AbstractSaxHtmlParser.access$2(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), atts));
  }
  
  public void end()
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).endBlock();
  }
  
  public void characters(String s)
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).characters(s);
  }
}

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

import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;

class AbstractSaxHtmlParser$DocumentBuilderAdapter$PreformattedBlockElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  private Attributes atts;
  
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$PreformattedBlockElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter)
  {
    super(paramDocumentBuilderAdapter, null);
  }
  
  void start(Attributes atts)
  {
    this.atts = new AttributesImpl(atts);
  }
  
  void end()
  {
    if (atts == null) {
      AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).endBlock();
    }
  }
  
  void characters(String s)
  {
    if (atts != null)
    {
      AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).beginBlock(DocumentBuilder.BlockType.PREFORMATTED, AbstractSaxHtmlParser.access$2(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), atts));
      atts = null;
    }
    super.characters(s);
  }
}

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

import java.util.List;
import java.util.Set;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.Visitor;

class SplitOutlineItem$1
  implements OutlineItem.Visitor
{
  SplitOutlineItem$1(SplitOutlineItem paramSplitOutlineItem, Set paramSet) {}
  
  public boolean visit(OutlineItem item)
  {
    SplitOutlineItem split = (SplitOutlineItem)item;
    if (val$pageTargets.add(split.getSplitTarget())) {
      SplitOutlineItem.access$1(this$0).add(split);
    }
    return true;
  }
}

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

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

class AbstractSaxHtmlParser$DocumentBuilderAdapter$SpanElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  private final DocumentBuilder.SpanType spanType;
  private boolean noop;
  
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$SpanElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter, DocumentBuilder.SpanType spanType)
  {
    super(paramDocumentBuilderAdapter, null);
    this.spanType = spanType;
  }
  
  public void start(org.xml.sax.Attributes atts)
  {
    org.eclipse.mylyn.wikitext.core.parser.Attributes attributes = AbstractSaxHtmlParser.access$3(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), spanType, atts);
    if ((spanType == DocumentBuilder.SpanType.SPAN) && (attributes.getCssClass() == null) && (attributes.getCssStyle() == null) && 
      (attributes.getId() == null)) {
      noop = true;
    } else {
      AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).beginSpan(spanType, attributes);
    }
  }
  
  public void end()
  {
    if (!noop) {
      AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).endSpan();
    }
  }
}

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

import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.xml.sax.Attributes;

abstract class AbstractSaxHtmlParser$DocumentBuilderAdapter$ElementHandler
{
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$ElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter) {}
  
  abstract void start(Attributes paramAttributes);
  
  abstract void end();
  
  void characters(String s)
  {
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).characters(s);
  }
}

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

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

class DitaTopicDocumentBuilder$BlockDescription
{
  DocumentBuilder.BlockType type;
  int size;
  int entrySize;
  final String[] nestedElementNames;
  final boolean closeElementsOnBlockStart;
  
  public DitaTopicDocumentBuilder$BlockDescription(DocumentBuilder.BlockType type, int size, String[] nestedElementNames, boolean closeElementsOnBlockStart)
  {
    this.size = size;
    entrySize = (nestedElementNames == null ? 0 : nestedElementNames.length);
    this.type = type;
    this.nestedElementNames = nestedElementNames;
    this.closeElementsOnBlockStart = closeElementsOnBlockStart;
  }
}

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

import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem;
import org.eclipse.mylyn.wikitext.core.parser.util.MarkupToEclipseToc;

public class SplittingMarkupToEclipseToc
  extends MarkupToEclipseToc
{
  protected String computeFile(OutlineItem item)
  {
    if ((item instanceof SplitOutlineItem))
    {
      String target = ((SplitOutlineItem)item).getSplitTarget();
      if (target != null) {
        return target;
      }
    }
    return super.computeFile(item);
  }
}

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

class DitaTopicDocumentBuilder$TopicInfo
{
  int headingLevel;
  int openElements;
}

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

import java.util.Map;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem;
import org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem.Visitor;

class SplitOutlineItem$2
  implements OutlineItem.Visitor
{
  SplitOutlineItem$2(SplitOutlineItem paramSplitOutlineItem, Map paramMap) {}
  
  public boolean visit(OutlineItem item)
  {
    if (item.getId() != null)
    {
      if (val$splitTargetById.containsKey(item.getId())) {
        throw new IllegalStateException(String.format("Duplicate id '%s'", new Object[] { item.getId() }));
      }
      val$splitTargetById.put(item.getId(), (SplitOutlineItem)item);
    }
    return true;
  }
}

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

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

class AbstractSaxHtmlParser$DocumentBuilderAdapter$ImageElementHandler
  extends AbstractSaxHtmlParser.DocumentBuilderAdapter.ElementHandler
{
  private AbstractSaxHtmlParser$DocumentBuilderAdapter$ImageElementHandler(AbstractSaxHtmlParser.DocumentBuilderAdapter paramDocumentBuilderAdapter)
  {
    super(paramDocumentBuilderAdapter, null);
  }
  
  public void start(org.xml.sax.Attributes atts)
  {
    org.eclipse.mylyn.wikitext.core.parser.Attributes attributes = AbstractSaxHtmlParser.access$3(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), DocumentBuilder.SpanType.SPAN, atts);
    AbstractSaxHtmlParser.DocumentBuilderAdapter.access$0(this$1).image(attributes, AbstractSaxHtmlParser.access$4(AbstractSaxHtmlParser.DocumentBuilderAdapter.access$1(this$1), "src", atts));
  }
  
  public void end() {}
}

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

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import org.eclipse.mylyn.internal.wikitext.core.util.ConcatenatingReader;
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

public class XHtmlParser
  extends AbstractSaxHtmlParser
{
  protected void parse(InputSource input, DocumentBuilder builder, ContentHandler contentHandler)
    throws IOException, SAXException
  {
    if (input == null) {
      throw new IllegalArgumentException();
    }
    if (builder == null) {
      throw new IllegalArgumentException();
    }
    XMLReader xmlReader = XMLReaderFactory.createXMLReader();
    xmlReader.setContentHandler(contentHandler);
    
    Reader reader = input.getCharacterStream();
    if (reader == null)
    {
      InputStream in = input.getByteStream();
      if (in == null) {
        throw new IllegalArgumentException("input must provide a byte stream or a character stream");
      }
      reader = new InputStreamReader(in, input.getEncoding() == null ? "utf-8" : input.getEncoding());
    }
    reader = new ConcatenatingReader(new Reader[] {
      new StringReader(
      "<?xml version='1.0'?><!DOCTYPE html [ <!ENTITY nbsp \"&#160;\"> <!ENTITY copy \"&#169;\"> <!ENTITY reg \"&#174;\"> <!ENTITY euro \"&#8364;\"> ]>"), reader });
    
    input = new InputSource(reader);
    xmlReader.parse(input);
  }
}

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

import java.util.MissingResourceException;
import java.util.ResourceBundle;

class Messages
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.wikitext.core.parser.builder.messages";
  private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("org.eclipse.mylyn.internal.wikitext.core.parser.builder.messages");
  
  public static String getString(String key)
  {
    try
    {
      return RESOURCE_BUNDLE.getString(key);
    }
    catch (MissingResourceException localMissingResourceException) {}
    return '!' + key + '!';
  }
}

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

import java.util.HashSet;
import java.util.Set;

public class DefaultSplittingStrategy
  extends SplittingStrategy
{
  private int headingCount;
  private int firstHeadingSplit = 2;
  private int headingLevel;
  private int splitLevel = 1;
  private String id;
  private String label;
  private String target;
  private final Set<String> targets = new HashSet();
  
  public void heading(int level, String id, String label)
  {
    if (level <= 0) {
      return;
    }
    this.label = label;
    this.id = id;
    headingLevel = level;
    headingCount += 1;
    if (isSplit()) {
      target = computeSplitTarget();
    }
  }
  
  public String getSplitTarget()
  {
    return target;
  }
  
  protected String computeSplitTarget()
  {
    String candidate = null;
    if (candidate == null)
    {
      if ((label != null) && (label.length() > 0)) {
        candidate = label.replaceAll("[^a-zA-Z0-9]+", "-");
      }
      if ((candidate == null) || (candidate.length() == 0)) {
        if (id != null) {
          candidate = id;
        } else {
          candidate = "h" + headingLevel + "p" + headingCount;
        }
      }
    }
    String computedTarget = candidate;
    int seed = 1;
    while (!targets.add(computedTarget)) {
      computedTarget = candidate + ++seed;
    }
    return computedTarget + ".html";
  }
  
  public boolean isSplit()
  {
    return (headingCount >= firstHeadingSplit) && (splitLevel >= headingLevel);
  }
  
  public int getFirstHeadingSplit()
  {
    return firstHeadingSplit;
  }
  
  public void setFirstHeadingSplit(int firstHeadingSplit)
  {
    this.firstHeadingSplit = firstHeadingSplit;
  }
  
  public int getSplitLevel()
  {
    return splitLevel;
  }
  
  public void setSplitLevel(int splitLevel)
  {
    this.splitLevel = splitLevel;
  }
}

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;
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.ImageAttributes;
import org.eclipse.mylyn.wikitext.core.parser.LinkAttributes;
import org.eclipse.mylyn.wikitext.core.parser.Locator;
import org.eclipse.mylyn.wikitext.core.parser.TableAttributes;
import org.eclipse.mylyn.wikitext.core.parser.TableCellAttributes;
import org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder.Stylesheet;

public class SplittingHtmlDocumentBuilder
  extends DocumentBuilder
{
  private SplitOutlineItem outline;
  private HtmlDocumentBuilder rootBuilder;
  private File rootFile;
  private boolean formatting;
  private HtmlDocumentBuilder out;
  private Writer writer;
  private File currentFile;
  private boolean navigationImages;
  private String navigationImagePath = "images";
  
  public void setRootBuilder(HtmlDocumentBuilder rootBuilder)
  {
    this.rootBuilder = rootBuilder;
    out = rootBuilder;
  }
  
  public HtmlDocumentBuilder getRootBuilder()
  {
    return rootBuilder;
  }
  
  public void beginDocument()
  {
    if ((rootBuilder == null) || (out == null) || (rootFile == null)) {
      throw new IllegalStateException();
    }
    currentFile = rootFile;
    out.beginDocument();
    documentHeader();
  }
  
  public void acronym(String text, String definition)
  {
    out.acronym(text, definition);
  }
  
  public void addCssStylesheet(HtmlDocumentBuilder.Stylesheet stylesheet)
  {
    out.addCssStylesheet(stylesheet);
  }
  
  public void beginBlock(DocumentBuilder.BlockType type, Attributes attributes)
  {
    out.beginBlock(type, attributes);
  }
  
  public void beginHeading(int level, Attributes attributes)
  {
    SplitOutlineItem item = outline.getOutlineItemById(attributes.getId());
    if ((item != null) && (!currentFile.getName().equals(item.getSplitTarget()))) {
      try
      {
        documentFooter();
        out.endDocument();
        if (writer != null)
        {
          writer.close();
          writer = null;
        }
        currentFile = new File(rootFile.getParent(), item.getSplitTarget());
        
        writer = new OutputStreamWriter(new FileOutputStream(currentFile), "UTF-8");
        HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatting);
        rootBuilder.copyConfiguration(builder);
        if (item.getLabel() != null)
        {
          String title = rootBuilder.getTitle();
          if (title == null) {
            title = item.getLabel();
          } else {
            title = title + " - " + item.getLabel();
          }
          builder.setTitle(title);
        }
        out = builder;
        out.beginDocument();
        
        documentHeader();
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
      }
    }
    out.beginHeading(level, attributes);
  }
  
  private void documentFooter()
  {
    emitNavigation(false);
  }
  
  private void emitNavigation(boolean header)
  {
    String currentName = currentFile.getName();
    List<SplitOutlineItem> pageOrder = outline.getPageOrder();
    SplitOutlineItem previous = null;
    SplitOutlineItem next = null;
    SplitOutlineItem current = null;
    boolean foundPage = false;
    for (SplitOutlineItem page : pageOrder) {
      if (page.getSplitTarget().equals(currentName))
      {
        foundPage = true;
        current = page;
      }
      else if (!foundPage)
      {
        previous = page;
      }
      else
      {
        next = page;
        break;
      }
    }
    boolean rootPage = rootFile.getName().equals(currentFile.getName());
    if ((next == null) && (previous == null) && (rootPage)) {
      return;
    }
    if (!header) {
      out.charactersUnescaped("<hr/>");
    }
    TableAttributes tableAttributes = new TableAttributes();
    tableAttributes.setCssClass("navigation");
    tableAttributes.setCssStyle("width: 100%;");
    tableAttributes.setBorder("0");
    tableAttributes.setSummary("navigation");
    out.beginBlock(DocumentBuilder.BlockType.TABLE, tableAttributes);
    if (header)
    {
      out.beginBlock(DocumentBuilder.BlockType.TABLE_ROW, new Attributes());
      
      TableCellAttributes tableCellAttributes = new TableCellAttributes();
      tableCellAttributes.setAlign("center");
      tableCellAttributes.setCssStyle("width: 100%");
      tableCellAttributes.setColspan("3");
      out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_HEADER, tableCellAttributes);
      if (rootPage) {
        out.characters(rootBuilder.getTitle());
      } else {
        out.characters(current == null ? "" : current.getLabel());
      }
      out.endBlock();
      
      out.endBlock();
    }
    out.beginBlock(DocumentBuilder.BlockType.TABLE_ROW, new Attributes());
    
    TableCellAttributes tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("left");
    tableCellAttributes.setCssStyle("width: 20%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    if (previous != null)
    {
      LinkAttributes linkAttributes = new LinkAttributes();
      linkAttributes.setTitle(previous.getLabel());
      if (navigationImages)
      {
        ImageAttributes imageAttributes = new ImageAttributes();
        imageAttributes.setAlt(Messages.getString("SplittingHtmlDocumentBuilder.Previous"));
        out.imageLink(linkAttributes, imageAttributes, previous.getSplitTarget(), 
          computeNavImagePath(Messages.getString("SplittingHtmlDocumentBuilder.Previous_Image")));
      }
      else
      {
        out.link(linkAttributes, previous.getSplitTarget(), 
          Messages.getString("SplittingHtmlDocumentBuilder.Previous"));
      }
    }
    out.endBlock();
    
    tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("center");
    tableCellAttributes.setCssStyle("width: 60%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    if ((!header) && (!rootPage))
    {
      LinkAttributes linkAttributes = new LinkAttributes();
      linkAttributes.setTitle(rootBuilder.getTitle());
      if (navigationImages)
      {
        ImageAttributes imageAttributes = new ImageAttributes();
        imageAttributes.setAlt(rootBuilder.getTitle());
        out.imageLink(linkAttributes, imageAttributes, rootFile.getName(), 
          computeNavImagePath(Messages.getString("SplittingHtmlDocumentBuilder.Home_Image")));
      }
      else
      {
        out.link(linkAttributes, rootFile.getName(), Messages.getString("SplittingHtmlDocumentBuilder.Home"));
      }
    }
    out.endBlock();
    
    tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("right");
    tableCellAttributes.setCssStyle("width: 20%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    if (next != null)
    {
      LinkAttributes linkAttributes = new LinkAttributes();
      linkAttributes.setTitle(next.getLabel());
      if (navigationImages)
      {
        ImageAttributes imageAttributes = new ImageAttributes();
        imageAttributes.setAlt(Messages.getString("SplittingHtmlDocumentBuilder.Next"));
        out.imageLink(linkAttributes, imageAttributes, next.getSplitTarget(), 
          computeNavImagePath(Messages.getString("SplittingHtmlDocumentBuilder.Next_Image")));
      }
      else
      {
        out.link(linkAttributes, next.getSplitTarget(), Messages.getString("SplittingHtmlDocumentBuilder.Next"));
      }
    }
    out.endBlock();
    
    out.endBlock();
    
    out.beginBlock(DocumentBuilder.BlockType.TABLE_ROW, new Attributes());
    
    tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("left");
    tableCellAttributes.setValign("top");
    tableCellAttributes.setCssStyle("width: 20%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    if (previous != null) {
      out.characters(previous.getLabel());
    }
    out.endBlock();
    
    tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("center");
    tableCellAttributes.setCssStyle("width: 60%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    
    out.endBlock();
    
    tableCellAttributes = new TableCellAttributes();
    tableCellAttributes.setAlign("right");
    tableCellAttributes.setValign("top");
    tableCellAttributes.setCssStyle("width: 20%");
    out.beginBlock(DocumentBuilder.BlockType.TABLE_CELL_NORMAL, tableCellAttributes);
    if (next != null) {
      out.characters(next.getLabel());
    }
    out.endBlock();
    
    out.endBlock();
    
    out.endBlock();
    if (header) {
      out.charactersUnescaped("<hr/>");
    }
  }
  
  private String computeNavImagePath(String imagePath)
  {
    if (navigationImagePath != null) {
      return navigationImagePath + "/" + imagePath;
    }
    return imagePath;
  }
  
  public String getNavigationImagePath()
  {
    return navigationImagePath;
  }
  
  public void setNavigationImagePath(String navigationImagePath)
  {
    this.navigationImagePath = navigationImagePath;
    if ((this.navigationImagePath != null) && (this.navigationImagePath.endsWith("/"))) {
      this.navigationImagePath = this.navigationImagePath.substring(0, this.navigationImagePath.length() - 1);
    }
  }
  
  private void documentHeader()
  {
    emitNavigation(true);
  }
  
  public void beginSpan(DocumentBuilder.SpanType type, Attributes attributes)
  {
    if ((type == DocumentBuilder.SpanType.LINK) && ((attributes instanceof LinkAttributes)))
    {
      LinkAttributes linkAttributes = (LinkAttributes)attributes;
      linkAttributes.setHref(adjustHref(linkAttributes.getHref()));
    }
    out.beginSpan(type, attributes);
  }
  
  public void characters(String text)
  {
    out.characters(text);
  }
  
  public void charactersUnescaped(String literal)
  {
    out.charactersUnescaped(literal);
  }
  
  public void copyConfiguration(HtmlDocumentBuilder other)
  {
    out.copyConfiguration(other);
  }
  
  public void endBlock()
  {
    out.endBlock();
  }
  
  public void endDocument()
  {
    documentFooter();
    out.endDocument();
    if (writer != null) {
      try
      {
        writer.close();
      }
      catch (IOException localIOException)
      {
        throw new IllegalStateException();
      }
    }
    out = null;
  }
  
  public void endHeading()
  {
    out.endHeading();
  }
  
  public void endSpan()
  {
    out.endSpan();
  }
  
  public void entityReference(String entity)
  {
    out.entityReference(entity);
  }
  
  public Locator getLocator()
  {
    return out.getLocator();
  }
  
  public void image(Attributes attributes, String url)
  {
    out.image(attributes, url);
  }
  
  public void imageLink(Attributes linkAttributes, Attributes imageAttributes, String href, String imageUrl)
  {
    href = adjustHref(href);
    out.imageLink(linkAttributes, imageAttributes, href, imageUrl);
  }
  
  private String adjustHref(String href)
  {
    if ((href != null) && (href.startsWith("#")))
    {
      SplitOutlineItem target = outline.getOutlineItemById(href.substring(1));
      if ((target != null) && (target.getSplitTarget() != null)) {
        href = target.getSplitTarget().replace(" ", "%20") + href;
      }
    }
    return href;
  }
  
  public void lineBreak()
  {
    out.lineBreak();
  }
  
  public void link(Attributes attributes, String hrefOrHashName, String text)
  {
    hrefOrHashName = adjustHref(hrefOrHashName);
    out.link(attributes, hrefOrHashName, text);
  }
  
  public void setLocator(Locator locator)
  {
    if (out != null) {
      out.setLocator(locator);
    }
  }
  
  public void setOutline(SplitOutlineItem outline)
  {
    this.outline = outline;
  }
  
  public SplitOutlineItem getOutline()
  {
    return outline;
  }
  
  public void setRootFile(File rootFile)
  {
    this.rootFile = rootFile;
  }
  
  public void setNavigationImages(boolean navigationImages)
  {
    this.navigationImages = navigationImages;
  }
  
  public boolean isNavigationImages()
  {
    return navigationImages;
  }
  
  public void setFormatting(boolean formatting)
  {
    this.formatting = formatting;
  }
  
  public boolean isFormatting()
  {
    return formatting;
  }
}

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

import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.wikitext.core.util.EclipseServiceLocator;
import org.eclipse.mylyn.internal.wikitext.core.validation.ValidationRules;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
import org.eclipse.mylyn.wikitext.core.util.ServiceLocator;
import org.eclipse.mylyn.wikitext.core.validation.MarkupValidator;
import org.eclipse.mylyn.wikitext.core.validation.ValidationRule;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public class WikiTextPlugin
  extends Plugin
{
  private static final String EXTENSION_MARKUP_LANGUAGE = "markupLanguage";
  private static final String EXTENSION_VALIDATION_RULES = "markupValidationRule";
  private static WikiTextPlugin plugin;
  private SortedMap<String, Class<? extends MarkupLanguage>> languageByName;
  private Map<String, Class<? extends MarkupLanguage>> languageByFileExtension;
  private Map<Class<? extends MarkupLanguage>, String> languageNameByLanguage;
  private Map<String, String> languageExtensionByLanguage;
  private Map<String, ValidationRules> validationRulesByLanguageName;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    ServiceLocator.setImplementation(EclipseServiceLocator.class);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    if (plugin == this) {
      plugin = null;
    }
    super.stop(context);
  }
  
  public static WikiTextPlugin getDefault()
  {
    return plugin;
  }
  
  public MarkupLanguage getMarkupLanguage(String name)
  {
    if (languageByName == null) {
      initializeMarkupLanguages();
    }
    Class<? extends MarkupLanguage> languageClass = (Class)languageByName.get(name);
    if (languageClass == null) {
      for (Map.Entry<String, Class<? extends MarkupLanguage>> entry : languageByName.entrySet())
      {
        Class<? extends MarkupLanguage> clazz = (Class)entry.getValue();
        if (clazz.getName().equals(name))
        {
          languageClass = clazz;
          name = (String)entry.getKey();
          break;
        }
      }
    }
    if (languageClass != null) {
      return instantiateMarkupLanguage(name, languageClass);
    }
    return null;
  }
  
  private MarkupLanguage instantiateMarkupLanguage(String name, Class<? extends MarkupLanguage> languageClass)
  {
    try
    {
      MarkupLanguage language = (MarkupLanguage)languageClass.newInstance();
      language.setName(name);
      language.setExtendsLanguage((String)languageExtensionByLanguage.get(name));
      return language;
    }
    catch (Exception e)
    {
      log(4, MessageFormat.format(Messages.getString("WikiTextPlugin.2"), new Object[] { name, 
        languageClass.getName(), e.getMessage() }), e);
    }
    return null;
  }
  
  public String getMarkupLanguageNameForFilename(String name)
  {
    if (languageByFileExtension == null) {
      initializeMarkupLanguages();
    }
    int lastIndexOfDot = name.lastIndexOf('.');
    String extension = lastIndexOfDot == -1 ? name : name.substring(lastIndexOfDot + 1);
    Class<? extends MarkupLanguage> languageClass = (Class)languageByFileExtension.get(extension);
    if (languageClass != null) {
      return (String)languageNameByLanguage.get(languageClass);
    }
    return null;
  }
  
  public Set<String> getMarkupFileExtensions()
  {
    if (languageByFileExtension == null) {
      initializeMarkupLanguages();
    }
    return Collections.unmodifiableSet(languageByFileExtension.keySet());
  }
  
  public MarkupLanguage getMarkupLanguageForFilename(String name)
  {
    if (languageByFileExtension == null) {
      initializeMarkupLanguages();
    }
    int lastIndexOfDot = name.lastIndexOf('.');
    String extension = lastIndexOfDot == -1 ? name : name.substring(lastIndexOfDot + 1);
    Class<? extends MarkupLanguage> languageClass = (Class)languageByFileExtension.get(extension);
    if (languageClass != null)
    {
      String languageName = null;
      for (Map.Entry<String, Class<? extends MarkupLanguage>> ent : languageByName.entrySet()) {
        if (ent.getValue() == languageClass)
        {
          languageName = (String)ent.getKey();
          break;
        }
      }
      return instantiateMarkupLanguage(languageName, languageClass);
    }
    return null;
  }
  
  public Set<String> getMarkupLanguageNames()
  {
    if (languageByName == null) {
      initializeMarkupLanguages();
    }
    return languageByName.keySet();
  }
  
  public MarkupValidator getMarkupValidator(String name)
  {
    MarkupValidator markupValidator = new MarkupValidator();
    if (validationRulesByLanguageName == null) {
      initializeValidationRules();
    }
    ValidationRules rules = (ValidationRules)validationRulesByLanguageName.get(name);
    if (rules != null) {
      markupValidator.getRules().addAll(rules.getRules());
    }
    return markupValidator;
  }
  
  private void initializeValidationRules()
  {
    initializeMarkupLanguages();
    synchronized (this)
    {
      if (this.validationRulesByLanguageName == null)
      {
        Map<String, ValidationRules> validationRulesByLanguageName = new HashMap();
        
        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getPluginId(), 
          "markupValidationRule");
        if (extensionPoint != null)
        {
          IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
          IConfigurationElement[] arrayOfIConfigurationElement1;
          int j = (arrayOfIConfigurationElement1 = configurationElements).length;
          for (int i = 0; i < j; i++)
          {
            IConfigurationElement element = arrayOfIConfigurationElement1[i];
            try
            {
              String markupLanguage = element.getAttribute("markupLanguage");
              if ((markupLanguage == null) || (markupLanguage.length() == 0)) {
                throw new Exception(Messages.getString("WikiTextPlugin.4"));
              }
              if (!languageByName.containsKey(markupLanguage)) {
                throw new Exception(MessageFormat.format(
                
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