Permalink
Browse files

Fix or suppress deprecation warnings (#528)

Plus some minor cleanup.
  • Loading branch information...
1 parent e6110a8 commit 81efd1f2045677edd01c6b9a33e39946ef22467c @apoluektov apoluektov committed with robertpanzer Oct 28, 2016
@@ -25,7 +25,7 @@
*/
public interface Asciidoctor {
- public static final String STRUCTURE_MAX_LEVEL = "STRUCTURE_MAX_LEVEL";
+ String STRUCTURE_MAX_LEVEL = "STRUCTURE_MAX_LEVEL";
/**
* Parse the AsciiDoc source input into an Document {@link DocumentRuby} and
@@ -656,7 +656,7 @@ void convert(Reader contentReader, Writer rendererWriter,
* @author lordofthejars
*
*/
- public static class Factory {
+ class Factory {
/**
* Creates a new instance of Asciidoctor.
@@ -22,6 +22,8 @@ public AbstractBlockImpl(AbstractBlock blockDelegate, Ruby runtime) {
this.delegate = blockDelegate;
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String title() {
return getTitle();
@@ -36,6 +38,8 @@ public boolean isTitle() {
return RubyUtils.invokeRubyMethod(delegate, "title?", new Object[0], Boolean.class);
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String style() {
return getStyle();
@@ -50,6 +54,8 @@ public String getCaption() {
return RubyUtils.invokeRubyMethod(delegate, "caption", new Object[0], String.class);
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public List<AbstractBlock> blocks() {
return getBlocks();
@@ -74,11 +80,15 @@ public boolean isBlocks() {
return RubyUtils.invokeRubyMethod(delegate, "blocks?", new Object[0], Boolean.class);
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public Object content() {
return getContent();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public Object getContent() {
return delegate.content();
@@ -28,6 +28,8 @@ public String id() {
return this.abstractNode.id();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String context() {
return getContext();
@@ -38,6 +40,8 @@ public String getContext() {
return this.abstractNode.getContext();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public AbstractNode parent() {
return getParent();
@@ -48,6 +52,8 @@ public AbstractNode getParent() {
return this.abstractNode.getParent();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public DocumentRuby document() {
return getDocument();
@@ -123,9 +129,11 @@ public String getRole() {
return this.abstractNode.getRole();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String role() {
- return this.abstractNode.role();
+ return getRole();
}
@Override
@@ -29,6 +29,8 @@
*
* @return page title
*/
+ @SuppressWarnings("deprecation")
+ @Deprecated
String title();
/**
@@ -47,6 +49,8 @@
*
* @return blocks contained within current Document.
*/
+ @SuppressWarnings("deprecation")
+ @Deprecated
List<AbstractBlock> blocks();
/**
@@ -3,11 +3,11 @@
public interface Inline extends AbstractNode {
@Deprecated
- public String render();
+ String render();
- public String convert();
+ String convert();
- public String getType();
+ String getType();
- public String getText();
+ String getText();
}
@@ -11,6 +11,8 @@ public InlineImpl(Inline delegate, Ruby ruby) {
this.delegate = delegate;
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String render() {
return delegate.render();
@@ -16,7 +16,7 @@ public ListImpl(ListNode delegate, Ruby rubyRuntime) {
@Override
public List<AbstractBlock> getItems() {
- return blocks();
+ return getBlocks();
}
@Override
@@ -31,6 +31,8 @@ public boolean isItems() {
return isBlocks();
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public String render() {
return listDelegate.render();
@@ -2,9 +2,9 @@
public interface ListItem extends AbstractBlock {
- public String getMarker();
+ String getMarker();
- public String getText();
+ String getText();
- public boolean hasText();
+ boolean hasText();
}
@@ -7,8 +7,8 @@
boolean hasItems();
@Deprecated
- public String render();
+ String render();
- public String convert();
+ String convert();
}
@@ -4,6 +4,6 @@
public interface Row {
- public List<Cell> getCells();
+ List<Cell> getCells();
}
@@ -4,11 +4,11 @@
public interface Table extends AbstractBlock {
- public static enum HorizontalAlignment {
+ enum HorizontalAlignment {
LEFT, CENTER, RIGHT
}
- public static enum VerticalAlignment {
+ enum VerticalAlignment {
TOP, BOTTOM, MIDDLE
}
@@ -81,7 +81,7 @@ public void setGrid(String grid) {
return rows.getHead();
}
- public static interface Rows {
+ public interface Rows {
List<Row> getHead();
List<Row> getFoot();
@@ -167,25 +167,25 @@ private DocumentHeader toDocumentHeader(DocumentRuby documentRuby) {
Document document = new Document(documentRuby, rubyRuntime);
- return DocumentHeader.createDocumentHeader((Title) document.doctitle(opts), documentRuby.title(),
+ return DocumentHeader.createDocumentHeader((Title) document.doctitle(opts), documentRuby.getTitle(),
documentRuby.getAttributes());
}
private StructuredDocument toDocument(DocumentRuby documentRuby, Ruby rubyRuntime, int maxDeepLevel) {
Document document = new Document(documentRuby, rubyRuntime);
- List<ContentPart> contentParts = getContents(document.blocks(), 1, maxDeepLevel);
+ List<ContentPart> contentParts = getContents(document.getBlocks(), 1, maxDeepLevel);
return StructuredDocument.createStructuredDocument(toDocumentHeader(documentRuby), contentParts);
}
private List<ContentPart> getContents(List<AbstractBlock> blocks, int level, int maxDeepLevel) {
- // finish getting childs if max structure level was riched
+ // finish getting children if max structure level was reached
if (level > maxDeepLevel) {
return null;
}
// if document has only one child don't treat as actual contentpart
// unless
- // it has no childs
+ // it has no children
/*
* if (blocks.size() == 1 && blocks.get(0).blocks().size() > 0) { return getContents(blocks.get(0).blocks(), 0,
* maxDeepLevel); }
@@ -199,16 +199,16 @@ private StructuredDocument toDocument(DocumentRuby documentRuby, Ruby rubyRuntim
}
private ContentPart getContentPartFromBlock(AbstractBlock child, int level, int maxDeepLevel) {
- Object content = child.content();
+ Object content = child.getContent();
String textContent;
if (content instanceof String) {
textContent = (String) content;
} else {
textContent = child.convert();
}
- ContentPart contentPart = ContentPart.createContentPart(child.id(), level, child.context(), child.title(),
- child.style(), child.role(), child.getAttributes(), textContent);
- contentPart.setParts(getContents(child.blocks(), level + 1, maxDeepLevel));
+ ContentPart contentPart = ContentPart.createContentPart(child.id(), level, child.getContext(), child.getTitle(),
+ child.getStyle(), child.getRole(), child.getAttributes(), textContent);
+ contentPart.setParts(getContents(child.getBlocks(), level + 1, maxDeepLevel));
return contentPart;
}
@@ -68,7 +68,7 @@
@Test
public void should_return_section_blocks() {
Document document = asciidoctor.load(DOCUMENT, new HashMap<String, Object>());
- Section section = (Section) document.blocks().get(1);
+ Section section = (Section) document.getBlocks().get(1);
assertThat(section.index(), is(0));
assertThat(section.sectname(), is("sect1"));
assertThat(section.special(), is(false));
@@ -144,7 +144,7 @@ public void should_be_able_to_manipulate_attributes() {
@Test
public void should_be_able_to_get_roles() {
Document document = asciidoctor.load(ROLE, new HashMap<String, Object>());
- AbstractBlock abstractBlock = document.blocks().get(0);
+ AbstractBlock abstractBlock = document.getBlocks().get(0);
assertThat(abstractBlock.getRole(), is("famous"));
assertThat(abstractBlock.hasRole("famous"), is(true));
//assertThat(abstractBlock.isRole(), is(true));
@@ -154,7 +154,7 @@ public void should_be_able_to_get_roles() {
@Test
public void should_be_able_to_get_reftext() {
Document document = asciidoctor.load(REFTEXT, new HashMap<String, Object>());
- AbstractBlock abstractBlock = document.blocks().get(0);
+ AbstractBlock abstractBlock = document.getBlocks().get(0);
assertThat(abstractBlock.getReftext(), is("the first section"));
assertThat(abstractBlock.isReftext(), is(true));
}
@@ -217,9 +217,9 @@ public void should_load_a_document_from_File() throws FileNotFoundException {
.compact(true).asMap();
File inputFile = classpath.getResource("rendersample.asciidoc");
Document document = asciidoctor.loadFile(inputFile, options);
- assertEquals(1, document.blocks().size());
- assertThat(document.blocks().get(0), instanceOf(Section.class));
- Section section = (Section) document.blocks().get(0);
+ assertEquals(1, document.getBlocks().size());
+ assertThat(document.getBlocks().get(0), instanceOf(Section.class));
+ Section section = (Section) document.getBlocks().get(0);
assertEquals(1, section.getBlocks().size());
assertEquals("<strong>Section A</strong> paragraph.", section.getBlocks().get(0).getContent());
}
@@ -35,7 +35,7 @@ public Object convert(AbstractNode node, String transform, Map<Object, Object> o
.append(section.getContent()).toString();
} else if (transform.equals("paragraph")) {
AbstractBlock block = (AbstractBlock) node;
- String content = (String) block.content();
+ String content = (String) block.getContent();
return new StringBuilder(content.replaceAll(LINE_SEPARATOR, " ")).append(LINE_SEPARATOR);
} else if (node instanceof ListNode) {
StringBuilder sb = new StringBuilder();
@@ -22,7 +22,7 @@ public Document process(Document document) {
this.document = document;
- final List<AbstractBlock> blocks = this.document.blocks();
+ final List<AbstractBlock> blocks = this.document.getBlocks();
for (int i = 0; i < blocks.size(); i++) {
final AbstractBlock currentBlock = blocks.get(i);

0 comments on commit 81efd1f

Please sign in to comment.