public final class ZUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ZUtils.ZExprKind
Enumerated type used to distinguish what kind of Z Expr is.
|
Modifier and Type | Field and Description |
---|---|
static Factory |
FACTORY |
static StandardZ |
STDZ_NAMELIST_CHECKER |
static Comparator<ZName> |
ZNAME_COMPARATOR |
static Comparator<ZName> |
ZNAME_IGNORE_STROKES_COMPARATOR |
Modifier and Type | Method and Description |
---|---|
static int |
applExprArity(ApplExpr term) |
static ZBranchList |
assertZBranchList(Term term) |
static ZDeclList |
assertZDeclList(Term term) |
static ZExprList |
assertZExprList(Term term) |
static ZFactoryImpl |
assertZFactoryImpl(Object factory) |
static ZFreetypeList |
assertZFreetypeList(Term term) |
static ZName |
assertZName(Term term) |
static ZNameList |
assertZNameList(Term term) |
static ZNumeral |
assertZNumeral(Term term) |
static ZParaList |
assertZParaList(Term term) |
static PrintVisitor |
assertZPrintVisitor(Object visitor) |
static ZSchText |
assertZSchText(Term term) |
static ZStrokeList |
assertZStrokeList(Term term) |
static TermImpl |
assertZTermImpl(Object term) |
static Name |
buildName(Factory factory,
Name name,
List<Stroke> strokes) |
static Name |
buildName(Name name,
List<Stroke> strokes) |
static <T extends Term> |
cloneTerm(T term)
Cloning terms
|
static int |
compareTo(ZName zName1,
ZName zName2) |
static int |
compareToIgnoreStrokes(ZName zName1,
ZName zName2) |
static boolean |
containsID(List<ZName> list,
ZName zName)
Test whether a list contains a ZName with the same ID.
|
static boolean |
containsObject(List<Term> list,
Object o)
Test whether a list contains a reference to an object.
|
static boolean |
containsZName(List<ZName> list,
ZName zName)
Test whether a list contains a ZName.
|
static Factory |
createConsoleFactory()
Useful factory for debugging purposes.
|
static Factory |
createFactory(boolean printUnicode,
boolean printNameIds,
int printLocLineOffset,
int printLocColOffset)
Create a factory tailored for either debugging or UI purposes.
|
static Expr |
getAbbreviationExpr(Term term) |
static Name |
getAbbreviationName(Term term) |
static ZNameList |
getAbbreviationZGenFormals(Term term) |
static ZExprList |
getApplExprArguments(Term term)
Returns the ApplExpr arguments for the given term if it is a
valid ApplExpr (i.e.
|
static Expr |
getApplExprRef(Term term)
Returns the ApplExpr reference expression for the given term if it is
a valid ApplExpr (i.e.
|
static ZDeclList |
getAxBoxDecls(Term term)
Returns the ZDeclList of axiomatic or generic definitions, or
null if term is not an AxPara with AxBox.
|
static Pred |
getAxBoxPred(Term term)
Returns the Pred of axiomatic or generic definitions, or null if
term is not an AxPara with AxBox.
|
static NameList |
getAxParaGenFormals(Term term)
Returns the generic formals as NameList of a given term if it is
AxPara or null otherwise.
|
static Name |
getAxParaSchOrAbbrName(Term term) |
static ZNameList |
getAxParaZGenFormals(Term term)
Returns the generic formals as ZNameList of a given term if it is
AxPara or null otherwise This is valid for any kind of
AxPara.
|
static ZExprList |
getGenOpApplZGenActuals(Term term)
Returns the list of instantiating expressions in Generic Operator
Application RefExpr or null if it isn't one.
|
static Expr |
getMemPredLHS(MemPred term)
Returns the LHS of a MemPred, which is just the same as
term.getLeftExpr()
|
static Expr |
getMemPredRHS(MemPred term)
Returns the RHS of a MemPred, which is just the same as
term.getReftExpr(), unless term is an equality, in which case it
returns the singleton set element of the RHS expression.
|
static int |
getRelOpApplPredArity(Term term)
Returns the relational operator application aritity (i.e.
|
static ZExprList |
getRelOpApplPredLHSArguments(Term term)
Returns the relational operator application arguments, or null if
term is not a MemPred relational operator application
(i.e.
|
static RefExpr |
getRelOpName(Term term)
Returns the relational operator name for the given term if
it is a relational operator MemPred (i.e.
|
static Expr |
getSchemaDefExpr(Term term) |
static Name |
getSchemaName(Term term)
If the given paragraph
isSimpleSchema(para) , returns the
declared schema name. |
static ZNameList |
getSchemaZGenFormals(Term term) |
static ZName |
getSpecialSchemaBaseName(Factory factory,
ZName zName)
Get the base name of a delta or xi reference.
|
static ZName |
getSpecialSchemaBaseName(ZName zName) |
static int |
getStrokeValue(Stroke stroke) |
static boolean |
idsEqual(String id1,
String id2) |
static void |
insert(List<NameTypePair> pairsA,
List<NameTypePair> pairsB)
Inserts all elements from pairsB in pairsA, provided pairsA are sorted.
|
static void |
insert(List<NameTypePair> pairs,
NameTypePair pair) |
static void |
insertNames(List<ZName> namesA,
List<ZName> namesB)
Inserts all elements from namesB in namesA, provided namesA are sorted.
|
static void |
insertNames(List<ZName> names,
ZName name) |
static boolean |
isAbbreviation(Term term)
Checks whether the given term
isHorizontalDef(Term)
and !isSimpleSchema(Term) |
static boolean |
isAndPred(Term term) |
static boolean |
isAnonymous(ZSect zSect) |
static boolean |
isApplExpr(Term term) |
static boolean |
isApplicationExpr(Term term)
Returns true if term is an application expression.
|
static boolean |
isApplicationExprValid(ApplExpr term)
Returns true whenever the given ApplExpr is valid (i.e.
|
static boolean |
isAxPara(Term term)
Checks whether the given term is an AxPara
|
static boolean |
isAxParaSchemaOrHorizDefValid(AxPara axp)
Returns true if the AxPara has been properly encoded as either a
schema box or a horizontal definition.
|
static boolean |
isBindSelExpr(Term term) |
static boolean |
isBoxedAxiomaticDef(Term term)
Return the generic formals of a given term if it is AxPara or
null otherwise
|
static boolean |
isBoxedGenericDef(Term term)
Checks whether the given term is an AxPara with AxBox (i.e.
|
static boolean |
isChainedConjunction(Term term)
Returns true if given term is an AndPred with And.Chain
|
static boolean |
isDelta(ZName zName) |
static boolean |
isDeltaXi(Name name) |
static boolean |
isDeltaXi(ZName zName) |
static boolean |
isEmptySetRefExpr(Object a)
Returns whether the given expression is an empty set as a reference to
ZString.EMPTYSET |
static boolean |
isEqualityPred(Term term)
Returns true if term is MemPred with Mixfix=true and the second
(right) expression is a singleton set containing the right-hand
side of the equality.
|
static boolean |
isExplicitGenInstExpr(Term term)
Another less common example would be (\_ \fun \_)[S, T].
|
static boolean |
isFcnOpApplExpr(Term term)
Returns true if term is an function operator application
expression.
|
static boolean |
isGenInstExpr(Term term)
Returns true if term is a generic operator instantiation.
|
static boolean |
isGenOpApplExpr(Term term)
Returns true if term is Generic Operator Application.
|
static boolean |
isHorizontalDef(Term term)
Checks whether the given term is an AxPara with OmixBox.
|
static boolean |
isHorizontalSchema(Term term)
Checks whether the given term
isHorizontalDef(Term)
and isSimpleSchema(Term) |
static boolean |
isLambdaExpr(Term term) |
static boolean |
isMembershipPred(Term term)
Returns true if term is MemPred with Mixfix=false, where the
first (left) expression is the element, and the second (right)
expression is the set.
|
static boolean |
isMemPred(Term term) |
static boolean |
isMemPredValid(MemPred term)
Returns true whenever the given MemPred is valid (i.e.
|
static boolean |
isNestedApplExpr(Term term)
Nested application expressions (e.g., (f~x)~y) are ApplExpr with
mixfix FALSE and left expr as an ApplExpr.
|
static boolean |
isReferenceExpr(Term term)
Returns true if term is a reference expression.
|
static boolean |
isRefExpr(Term term) |
static boolean |
isRefExprValid(RefExpr term)
Returns true whenever the given RefExpr is valid (i.e.
|
static boolean |
isRelOpApplPred(Term term)
Returns true if term is MemPred with Mixfix=true, and the second
(right) expression is the operator name.
|
static boolean |
isSetExpr(Term term) |
static boolean |
isSimpleSchema(Term term)
Checks whether the given paragraph is an
AxPara term
encoded as a schema or not. |
static boolean |
isTupleExpr(Term term) |
static boolean |
isTupleSelExpr(Term term) |
static boolean |
isXi(ZName zName) |
static boolean |
isZPara(Term term)
Returns true if the given term is either a boxed or unboxed Z paragraph.
|
static boolean |
namesEqual(Name name1,
Name name2)
Test whether the base name and strokes of two Names are equal.
|
static boolean |
namesEqual(ZName zName1,
ZName zName2)
Test whether the base name and strokes of two ZNames are equal.
|
static Set<String> |
parentsArgListAsSetOfString(String... p)
Given a var-arg list of strings, transforms it into a set of strings (i.e.
|
static List<Parent> |
parentsAsListOfParent(Set<String> parents)
Transforms the set of string parents into list of AST Parents
|
static Set<Parent> |
parentsAsSetOfParent(Set<String> parents)
Transforms the set of string parents into set of AST Parents
|
static String |
parentsAsString(Set<String> parents)
Given a set of parent sections return it as a CSV string.
|
static Set<String> |
parentsCSVAsSetOfString(String p)
Gets a CSV string of Z section parents and transforms it back to a set of string
Should satisfy the invariant akin parentsAsString(parentsCSVAsSetOfString(s)) = s (ignoring order).
|
static ZSect |
retrieveZSect(Spec term,
String sectName) |
static void |
setToStringVisitor(Term term,
PrintVisitor printer) |
protected static void |
setZFactoryToStringVisitor(Factory f,
Visitor<String> toStringVisitor)
;
Changes the toString() method of ZFactory (within the given Factory),
so that is uses the toString() strategy for the given visitor, usually
one kind of PrintVisitor.
|
static List<NameTypePair> |
sort(List<NameTypePair> pairs)
Sorts the list of name type pairs given.
|
static Signature |
sort(Signature signature)
Sorts the name type pairs within the given signature.
|
static List<ZName> |
sortNames(List<ZName> names) |
static String |
strokeListToString(List<Stroke> strokes)
Transforms a list of strokes into a (unicode) string.
|
static List<NameTypePair> |
subsignature(Signature sig,
Class<?> decor)
Computes a list of all the NameTypePairs from the given signature
whose name ends with the given decoration.
|
static String |
toStringZName(ZName name) |
static String |
toStringZName(ZName name,
boolean printUnicode,
boolean printIds) |
static String |
trimNLCharAware(String string)
Trims the given string considering Z NLCHAR before and after.
|
static void |
unicodeToAscii(String name,
StringBuffer result) |
static ZUtils.ZExprKind |
whatKindOfZExpr(Expr term)
Returns whether or not a given expression is part of schema calculus
|
public static final Factory FACTORY
public static final Comparator<ZName> ZNAME_COMPARATOR
public static final Comparator<ZName> ZNAME_IGNORE_STROKES_COMPARATOR
public static final StandardZ STDZ_NAMELIST_CHECKER
public static Factory createConsoleFactory()
public static Factory createFactory(boolean printUnicode, boolean printNameIds, int printLocLineOffset, int printLocColOffset)
printUnicode
- printNameIds
- printLocLineOffset
- printLocColOffset
- public static void setToStringVisitor(Term term, PrintVisitor printer)
public static List<NameTypePair> subsignature(Signature sig, Class<?> decor)
decor
is null
a list of all undecored names with its
corresponding types is returned.public static boolean isAnonymous(ZSect zSect)
public static String parentsAsString(Set<String> parents)
parents
- public static String trimNLCharAware(String string)
string
- public static Set<String> parentsCSVAsSetOfString(String p)
p
- public static Set<Parent> parentsAsSetOfParent(Set<String> parents)
parents
- public static List<Parent> parentsAsListOfParent(Set<String> parents)
parents
- public static Set<String> parentsArgListAsSetOfString(String... p)
parents
- public static boolean isZPara(Term term)
public static ZUtils.ZExprKind whatKindOfZExpr(Expr term)
expr
- public static boolean isAxPara(Term term)
public static NameList getAxParaGenFormals(Term term)
public static ZNameList getAxParaZGenFormals(Term term)
public static ZDeclList getAxBoxDecls(Term term)
public static Pred getAxBoxPred(Term term)
public static boolean isBoxedAxiomaticDef(Term term)
public static boolean isBoxedGenericDef(Term term)
public static boolean isHorizontalDef(Term term)
public static boolean isHorizontalSchema(Term term)
isHorizontalDef(Term)
and isSimpleSchema(Term)
public static boolean isAbbreviation(Term term)
isHorizontalDef(Term)
and !isSimpleSchema(Term)
public static boolean isAxParaSchemaOrHorizDefValid(AxPara axp)
public static boolean isSimpleSchema(Term term)
AxPara
term
encoded as a schema or not. That is, it checks whether the term
is properly encoded as either a horizontal or a boxed schema.
Note that this does not include schema calculus constructs like
R == S \land T on schemas S and T, but just SchExpr (usual) schemas.
For the latter we need to rely on typing information.public static boolean isDeltaXi(Name name)
public static boolean isDeltaXi(ZName zName)
public static boolean isXi(ZName zName)
public static boolean isDelta(ZName zName)
public static <T extends Term> T cloneTerm(T term)
T
- term
- public static boolean containsObject(List<Term> list, Object o)
list
- the list to search.o
- the reference to search for.public static ZName getSpecialSchemaBaseName(Factory factory, ZName zName)
public static Name getSchemaName(Term term)
isSimpleSchema(para)
, returns the
declared schema name. Otherwise, the method returns null.public static boolean isEmptySetRefExpr(Object a)
ZString.EMPTYSET.
public static boolean isRefExpr(Term term)
public static boolean isApplExpr(Term term)
public static boolean isSetExpr(Term term)
public static boolean isTupleExpr(Term term)
public static boolean isBindSelExpr(Term term)
public static boolean isTupleSelExpr(Term term)
public static boolean isLambdaExpr(Term term)
public static boolean isMemPred(Term term)
public static boolean isAndPred(Term term)
public static boolean isReferenceExpr(Term term)
public static boolean isGenInstExpr(Term term)
public static boolean isExplicitGenInstExpr(Term term)
public static boolean isGenOpApplExpr(Term term)
public static boolean isRefExprValid(RefExpr term)
public static ZExprList getGenOpApplZGenActuals(Term term)
public static boolean isFcnOpApplExpr(Term term)
public static boolean isApplicationExpr(Term term)
public static boolean isNestedApplExpr(Term term)
term
- public static boolean isApplicationExprValid(ApplExpr term)
public static Expr getApplExprRef(Term term)
public static ZExprList getApplExprArguments(Term term)
public static int applExprArity(ApplExpr term)
public static boolean isEqualityPred(Term term)
public static boolean isRelOpApplPred(Term term)
public static boolean isMembershipPred(Term term)
public static boolean isMemPredValid(MemPred term)
public static Expr getMemPredLHS(MemPred term)
public static Expr getMemPredRHS(MemPred term)
public static RefExpr getRelOpName(Term term)
public static ZExprList getRelOpApplPredLHSArguments(Term term)
public static int getRelOpApplPredArity(Term term)
public static boolean isChainedConjunction(Term term)
public static void unicodeToAscii(String name, StringBuffer result)
public static String toStringZName(ZName name, boolean printUnicode, boolean printIds)
protected static void setZFactoryToStringVisitor(Factory f, Visitor<String> toStringVisitor)
; Changes the toString() method of ZFactory (within the given Factory), so that is uses the toString() strategy for the given visitor, usually one kind of PrintVisitor.
They are important in order to debug/inspect easily the rather complex scoping mechanisms for basic (locally declared) processes.
f
- factorytoStringVisitor
- new visitorpublic static ZBranchList assertZBranchList(Term term)
public static ZFreetypeList assertZFreetypeList(Term term)
public static ZStrokeList assertZStrokeList(Term term)
public static ZFactoryImpl assertZFactoryImpl(Object factory)
public static PrintVisitor assertZPrintVisitor(Object visitor)
public static String strokeListToString(List<Stroke> strokes)
public static boolean namesEqual(ZName zName1, ZName zName2)
public static boolean namesEqual(Name name1, Name name2)
public static boolean containsZName(List<ZName> list, ZName zName)
list
- the list to search.zName
- the ZName to search for.public static boolean containsID(List<ZName> list, ZName zName)
list
- the list to search.zName
- the ZName to search for.public static Signature sort(Signature signature)
public static List<NameTypePair> sort(List<NameTypePair> pairs)
public static void insert(List<NameTypePair> pairsA, List<NameTypePair> pairsB)
public static void insertNames(List<ZName> namesA, List<ZName> namesB)
public static void insert(List<NameTypePair> pairs, NameTypePair pair)
public static int getStrokeValue(Stroke stroke)
Copyright © 2003–2016 Community Z Tools Project. All rights reserved.