Пример #1
0
  /**
   * createDocument
   *
   * @param partitionType
   * @param source
   * @return
   */
  static IDocument createDocument(String source) {
    CompositePartitionScanner partitionScanner =
        new CompositePartitionScanner(
            CSSSourceConfiguration.getDefault().createSubPartitionScanner(),
            new NullSubPartitionScanner(),
            new NullPartitionerSwitchStrategy());
    IDocumentPartitioner partitioner =
        new ExtendedFastPartitioner(
            partitionScanner, CSSSourceConfiguration.getDefault().getContentTypes());
    partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);

    final IDocument document = new Document(source);
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);

    return document;
  }
 private String getContentType(String content, int offset) {
   if (partitioner == null) {
     IDocument document = new Document(content);
     CompositePartitionScanner partitionScanner =
         new CompositePartitionScanner(
             HTMLSourceConfiguration.getDefault().createSubPartitionScanner(),
             RubySourceConfiguration.getDefault().createSubPartitionScanner(),
             ERBPartitionerSwitchStrategy.getDefault());
     partitioner =
         new ExtendedFastPartitioner(
             partitionScanner,
             TextUtils.combine(
                 new String[][] {
                   CompositePartitionScanner.SWITCHING_CONTENT_TYPES,
                   HTMLSourceConfiguration.getDefault().getContentTypes(),
                   RubySourceConfiguration.getDefault().getContentTypes()
                 }));
     partitionScanner.setPartitioner(partitioner);
     partitioner.connect(document);
     document.setDocumentPartitioner(partitioner);
   }
   return partitioner.getContentType(offset);
 }