private void read ( Term term ) { if ( term . isNumber ( ) ) { NumericType numericType = ( NumericType ) term ; if ( numericType . isInteger ( ) ) { IntLiteral jplInteger = ( IntLiteral ) term ; getContentHandler ( ) . startIntegerTerm ( jplInteger . longValue ( ) ) ; } else if ( numericType . isFloat ( ) ) { FloatLiteral jplFloat = ( FloatLiteral ) term ; getContentHandler ( ) . startFloatTerm ( jplFloat . doubleValue ( ) ) ; } } else if ( term . isVar ( ) ) { Variable var = ( Variable ) term ; getContentHandler ( ) . startVariable ( interner . getVariableName ( var . getName ( ) ) ) ; } else if ( term . isAtom ( ) ) { Functor atom = ( Functor ) term ; getContentHandler ( ) . startAtom ( interner . getFunctorName ( atom . getName ( ) ) ) ; } else if ( term . isCompound ( ) ) { Functor functor = ( Functor ) term ; getContentHandler ( ) . startCompound ( ) ; getContentHandler ( ) . startAtom ( interner . getFunctorName ( functor . getName ( ) ) ) ; for ( com . thesett . aima . logic . fol . Term child : functor . getArguments ( ) ) { read ( child ) ; } getContentHandler ( ) . endCompound ( ) ; } else { throw new IllegalStateException ( "Unrecognized Lojix term: " + term ) ; } }
Reads a Lojix term and invoked appropriate methods on the content handler to describe its structure and contents to it .