001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.parsers.creole.ast;
016    
017    import com.liferay.portal.parsers.creole.visitor.ASTVisitor;
018    
019    /**
020     * @author Miguel Pastor
021     */
022    public class HeadingNode
023            extends BaseParentableNode implements Comparable<HeadingNode> {
024    
025            public HeadingNode(CollectionNode collectionNode, int level) {
026                    super(collectionNode);
027    
028                    _level = level;
029            }
030    
031            public HeadingNode(int level) {
032                    _level = level;
033            }
034    
035            @Override
036            public void accept(ASTVisitor astVisitor) {
037                    astVisitor.visit(this);
038            }
039    
040            @Override
041            public int compareTo(HeadingNode headingNode) {
042                    if (_level < headingNode.getLevel()) {
043                            return -1;
044                    }
045                    else if (_level > headingNode.getLevel()) {
046                            return 1;
047                    }
048                    else {
049                            return 0;
050                    }
051            }
052    
053            public int getLevel() {
054                    return _level;
055            }
056    
057            public void setLevel(int level) {
058                    _level = level;
059            }
060    
061            private int _level;
062    
063    }