![JAR search and dependency download from the Maven repository](/logo.png)
xyz.cofe.text.ast.AstNode Maven / Gradle / Ivy
The newest version!
/*
* The MIT License
*
* Copyright 2015 [email protected].
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package xyz.cofe.text.ast;
import java.util.logging.Level;
import java.util.logging.Logger;
import xyz.cofe.collection.BasicVisitor;
import xyz.cofe.collection.Iterators;
import xyz.cofe.collection.NodesExtracter;
import xyz.cofe.collection.Visitor;
import xyz.cofe.collection.tree.AbstractTreeNode;
/**
*
* @author [email protected]
*/
public abstract class AstNode
extends AbstractTreeNode
{
//
private static void logFine(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.FINE, message, args);
}
private static void logFiner(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.FINER, message, args);
}
private static void logFinest(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.FINEST, message, args);
}
private static void logInfo(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.INFO, message, args);
}
private static void logWarning(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.WARNING, message, args);
}
private static void logSevere(String message,Object ... args){
Logger.getLogger(AstNode.class.getName()).log(Level.SEVERE, message, args);
}
private static void logException(Throwable ex){
Logger.getLogger(AstNode.class.getName()).log(Level.SEVERE, null, ex);
}
//
protected AstNode[] children( AstNode ... nodes ){
return nodes;
}
public static final NodesExtracter astNodeExtracter
= new NodesExtracter() {
@Override
public Iterable extract(AstNode from) {
if( from!=null ){
return
Iterators.notNullFilter(
Iterators.array(from.getChildren())
);
}
return null;
}
};
public static void visit( AstNode tree, Visitor visitor){
if( visitor==null )throw new IllegalArgumentException( "visitor==null" );
if( tree==null )throw new IllegalArgumentException( "tree==null" );
BasicVisitor.visit(visitor, tree, astNodeExtracter);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy