Character.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Magnitudes;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Collections.*;
import Hoot.Collections.String;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import Hoot.Collections.Interval;
import Hoot.Magnitudes.Integer;
import Smalltalk.Core.Subject;
import Smalltalk.Magnitudes.Code;
import Smalltalk.Magnitudes.Ordinal;
import Smalltalk.Streams.StreamedSink;
public class Character extends Integer implements Code
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Integer.Metaclass implements Code.Metatype
{
static final Character.Metaclass $class = new Character.Metaclass();
public Metaclass() {
this(Character.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return Character.class; }
/**
* @return
*/
public Character nullCode()
{
java.lang.String exitID = "CharacterMetatype>>nullCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(0)));
});
}
/**
* @return
*/
public Character backspace()
{
java.lang.String exitID = "CharacterMetatype>>backspace";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.bsCode());
});
}
/**
* @return
*/
public Character bsCode()
{
java.lang.String exitID = "CharacterMetatype>>bsCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(8)));
});
}
/**
* @return
*/
public Character cr()
{
java.lang.String exitID = "CharacterMetatype>>cr";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.crCode());
});
}
/**
* @return
*/
public Character carriageReturn()
{
java.lang.String exitID = "CharacterMetatype>>carriageReturn";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.crCode());
});
}
/**
* @return
*/
public Character crCode()
{
java.lang.String exitID = "CharacterMetatype>>crCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(13)));
});
}
/**
* @return
*/
public Character lf()
{
java.lang.String exitID = "CharacterMetatype>>lf";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.lfCode());
});
}
/**
* @return
*/
public Character lineFeed()
{
java.lang.String exitID = "CharacterMetatype>>lineFeed";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.lfCode());
});
}
/**
* @return
*/
public Character newLine()
{
java.lang.String exitID = "CharacterMetatype>>newLine";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.lfCode());
});
}
/**
* @return
*/
public Character lfCode()
{
java.lang.String exitID = "CharacterMetatype>>lfCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(10)));
});
}
/**
* @return
*/
public Character delete()
{
java.lang.String exitID = "CharacterMetatype>>delete";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.delCode());
});
}
/**
* @return
*/
public Character delCode()
{
java.lang.String exitID = "CharacterMetatype>>delCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(127)));
});
}
/**
* @return
*/
public Character escape()
{
java.lang.String exitID = "CharacterMetatype>>escape";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.esc());
});
}
/**
* @return
*/
public Character esc()
{
java.lang.String exitID = "CharacterMetatype>>esc";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.escCode());
});
}
/**
* @return
*/
public Character escCode()
{
java.lang.String exitID = "CharacterMetatype>>escCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(27)));
});
}
/**
* @return
*/
public Character newPage()
{
java.lang.String exitID = "CharacterMetatype>>newPage";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.ffCode());
});
}
/**
* @return
*/
public Character formFeed()
{
java.lang.String exitID = "CharacterMetatype>>formFeed";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.ffCode());
});
}
/**
* @return
*/
public Character ffCode()
{
java.lang.String exitID = "CharacterMetatype>>ffCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(12)));
});
}
/**
* @return
*/
public Character space()
{
java.lang.String exitID = "CharacterMetatype>>space";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.spaceCode());
});
}
/**
* @return
*/
public Character spaceCode()
{
java.lang.String exitID = "CharacterMetatype>>spaceCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(32)));
});
}
/**
* @return
*/
public Character tab()
{
java.lang.String exitID = "CharacterMetatype>>tab";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.tabCode());
});
}
/**
* @return
*/
public Character tabCode()
{
java.lang.String exitID = "CharacterMetatype>>tabCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(9)));
});
}
/**
* @return
*/
public Character quote()
{
java.lang.String exitID = "CharacterMetatype>>quote";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.quoteCode());
});
}
/**
* @return
*/
public Character quoteCode()
{
java.lang.String exitID = "CharacterMetatype>>quoteCode";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(SmallInteger.from(39)));
});
}
/**
* @return
*/
public Boolean isAlphaNumeric(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>isAlphaNumeric";
Frame f0 = new Frame(exitID);
return Boolean.from(java.lang.Character.isLetterOrDigit(aCharacter.primitiveCharacter()));
}
/**
* @return
*/
public Boolean isDigit(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>isDigit";
Frame f0 = new Frame(exitID);
return Boolean.from(java.lang.Character.isDigit(aCharacter.primitiveCharacter()));
}
/**
* @return
*/
public Boolean isLetter(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>isLetter";
Frame f0 = new Frame(exitID);
return Boolean.from(java.lang.Character.isLetter(aCharacter.primitiveCharacter()));
}
/**
* @return
*/
public Boolean isLowercase(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>isLowercase";
Frame f0 = new Frame(exitID);
return Boolean.from(java.lang.Character.isLowerCase(aCharacter.primitiveCharacter()));
}
/**
* @return
*/
public Boolean isUppercase(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>isUppercase";
Frame f0 = new Frame(exitID);
return Boolean.from(java.lang.Character.isUpperCase(aCharacter.primitiveCharacter()));
}
/**
* @return
*/
public java.lang.String toString(final Character aCharacter)
{
java.lang.String exitID = "CharacterMetatype>>toString";
Frame f0 = new Frame(exitID);
return java.lang.String.valueOf(aCharacter.primitiveCharacter());
}
/**
* @return
*/
@Override protected void initialize()
{
java.lang.String exitID = "CharacterMetatype>>initialize";
Frame f0 = new Frame(exitID);
if ((AsciiCharacters.size() == 0)) {
Character.initializeFlyweights();
};
}
/**
* @return
*/
public Character codePoint(final Ordinal codePoint)
{
java.lang.String exitID = "CharacterMetatype>>codePoint";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.from(codePoint.intValue()));
});
}
/**
* @return
*/
public Character value(final Ordinal codePoint)
{
java.lang.String exitID = "CharacterMetatype>>value";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.codePoint(codePoint));
});
}
/**
* @return
*/
@Override public Character coerce(final Number aNumber)
{
java.lang.String exitID = "CharacterMetatype>>coerce";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.from(aNumber.primitiveInteger()));
});
}
/**
* @return
*/
public Character from(final SmallInteger anInteger)
{
java.lang.String exitID = "CharacterMetatype>>from";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.from(anInteger.intValue()));
});
}
/**
* @return
*/
public Character from(final int intValue)
{
java.lang.String exitID = "CharacterMetatype>>from";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Character)f0.exit(exitID, this.from(((char)intValue)));
});
}
/**
* @return
*/
public Character from(final char charValue)
{
java.lang.String exitID = "CharacterMetatype>>from";
Frame f0 = new Frame(exitID);
if ((charValue < AsciiMaximum)) {
return AsciiCharacters.get(charValue);
};
return new Character(charValue);
}
}
protected static SmallInteger Generality = SmallInteger.from(5);
private static final int AsciiMaximum = SmallInteger.from(256).primitiveInteger();
private static final List<Character> AsciiCharacters = new ArrayList();
private char primitiveValue = SmallInteger.from(0).primitiveCharacter();
private static final String [] Vowels = {
String.from("a"), String.from("e"), String.from("i"), String.from("o"), String.from("u")
};
private static final List<String> VowelList = Arrays.asList(Vowels);
/**
* @return
*/
private static void initializeFlyweights()
{
java.lang.String exitID = "Character>>$initializeFlyweights";
Frame f0 = new Frame(exitID);
int charValue = 0;
while((charValue < AsciiMaximum)) {
AsciiCharacters.add(new Character(((char)charValue)));
charValue += 1;
};
}
/**
* @return
*/
public static Character from(final SmallInteger anInteger)
{
java.lang.String exitID = "Character>>$from";
Frame f0 = new Frame(exitID);
return (Character)new Character(anInteger.primitiveCharacter());
}
/**
* @return
*/
public static Character from(final char aCharacter)
{
java.lang.String exitID = "Character>>$from";
Frame f0 = new Frame(exitID);
return (Character)new Character(aCharacter);
}
/**
*
*/
protected Character(final char charValue)
{
this();
java.lang.String exitID = "Character>>Character";
Frame f0 = new Frame(exitID);
primitiveValue = charValue;
}
/**
*
*/
protected Character()
{
super();
java.lang.String exitID = "Character>>Character";
Frame f0 = new Frame(exitID);
}
/**
* @return
*/
@Override public char primitiveCharacter()
{
java.lang.String exitID = "Character>>primitiveCharacter";
Frame f0 = new Frame(exitID);
return (char)primitiveValue;
}
/**
* @return
*/
public char asPrimitive()
{
java.lang.String exitID = "Character>>asPrimitive";
Frame f0 = new Frame(exitID);
return (char)this.primitiveCharacter();
}
/**
* @return
*/
@Override public int primitiveInteger()
{
java.lang.String exitID = "Character>>primitiveInteger";
Frame f0 = new Frame(exitID);
return (int)primitiveValue;
}
/**
* @return
*/
@Override public java.lang.Number elementaryNumber()
{
java.lang.String exitID = "Character>>elementaryNumber";
Frame f0 = new Frame(exitID);
return (java.lang.Number)this.elementaryInteger();
}
/**
* @return
*/
@Override public java.lang.Integer elementaryInteger()
{
java.lang.String exitID = "Character>>elementaryInteger";
Frame f0 = new Frame(exitID);
return (java.lang.Integer)((int)primitiveValue);
}
/**
* @return
*/
@Override public Character asCharacter()
{
java.lang.String exitID = "Character>>asCharacter";
Frame f0 = new Frame(exitID);
return (Character)this;
}
/**
* @return
*/
@Override public Integer asInteger()
{
java.lang.String exitID = "Character>>asInteger";
Frame f0 = new Frame(exitID);
return (Integer)SmallInteger.from(this.primitiveInteger());
}
/**
* @return
*/
public String asString()
{
java.lang.String exitID = "Character>>asString";
Frame f0 = new Frame(exitID);
return (String)String.from(Character.type().toString(this));
}
/**
* @return
*/
public Character asLowerCase()
{
java.lang.String exitID = "Character>>asLowerCase";
Frame f0 = new Frame(exitID);
return (Character)this.asLowercase();
}
/**
* @return
*/
public Character asLowercase()
{
java.lang.String exitID = "Character>>asLowercase";
Frame f0 = new Frame(exitID);
return (Character)Character.type().from(java.lang.Character.toLowerCase(this.asPrimitive()));
}
/**
* @return
*/
public Character asUpperCase()
{
java.lang.String exitID = "Character>>asUpperCase";
Frame f0 = new Frame(exitID);
return (Character)this.asUppercase();
}
/**
* @return
*/
public Character asUppercase()
{
java.lang.String exitID = "Character>>asUppercase";
Frame f0 = new Frame(exitID);
return (Character)Character.type().from(java.lang.Character.toUpperCase(this.asPrimitive()));
}
/**
* @return
*/
public Integer codePoint()
{
java.lang.String exitID = "Character>>codePoint";
Frame f0 = new Frame(exitID);
return (Integer)this.asInteger();
}
/**
* @return
*/
@Override public SmallInteger generality()
{
java.lang.String exitID = "Character>>generality";
Frame f0 = new Frame(exitID);
return (SmallInteger)Generality;
}
/**
* @return
*/
public final Boolean equals(final Character aNumber)
{
java.lang.String exitID = "Character>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((primitiveValue == aNumber.primitiveCharacter()));
}
/**
* @return
*/
public final Boolean lessThan(final Character aNumber)
{
java.lang.String exitID = "Character>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((primitiveValue < aNumber.primitiveCharacter()));
}
/**
* @return
*/
public final Boolean moreThan(final Character aNumber)
{
java.lang.String exitID = "Character>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((primitiveValue > aNumber.primitiveCharacter()));
}
/**
* @return
*/
@Override public Boolean equals(final Magnitude aNumber)
{
java.lang.String exitID = "Character>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Number.type().accepts(aNumber).and(Predicate.with(f2 -> {
return (((Number)aNumber).asCharacter().equals(this));
}, ""));
}
/**
* @return
*/
public Boolean lessThan(final Number aNumber)
{
java.lang.String exitID = "Character>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)(aNumber.asCharacter().moreThan(this));
}
/**
* @return
*/
public Boolean moreThan(final Number aNumber)
{
java.lang.String exitID = "Character>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)(aNumber.asCharacter().lessThan(this));
}
/**
* @return
*/
@Override public Boolean in(final Interval aRange)
{
java.lang.String exitID = "Character>>in";
Frame f0 = new Frame(exitID);
return (Boolean)aRange.includes(this);
}
/**
* @return
*/
@Override public int hashCode()
{
java.lang.String exitID = "Character>>hashCode";
Frame f0 = new Frame(exitID);
return (int)this.primitiveInteger();
}
/**
* @return
*/
@Override public Character printOn(final StreamedSink aStream)
{
java.lang.String exitID = "Character>>printOn";
Frame f0 = new Frame(exitID);
aStream.nextPut(this);
return (Character)this;
}
/**
* @return
*/
@Override public String printString()
{
java.lang.String exitID = "Character>>printString";
Frame f0 = new Frame(exitID);
return (String)String.from(java.lang.String.valueOf(this.primitiveCharacter()));
}
/**
* @return
*/
public Boolean isDigit()
{
java.lang.String exitID = "Character>>isDigit";
Frame f0 = new Frame(exitID);
return (Boolean)Character.type().isDigit(this);
}
/**
* @return
*/
public Boolean isLetter()
{
java.lang.String exitID = "Character>>isLetter";
Frame f0 = new Frame(exitID);
return (Boolean)Character.type().isLetter(this);
}
/**
* @return
*/
public Boolean isAlphaNumeric()
{
java.lang.String exitID = "Character>>isAlphaNumeric";
Frame f0 = new Frame(exitID);
return (Boolean)Character.type().isAlphaNumeric(this);
}
/**
* @return
*/
public Boolean isLowercase()
{
java.lang.String exitID = "Character>>isLowercase";
Frame f0 = new Frame(exitID);
return (Boolean)Character.type().isLowercase(this);
}
/**
* @return
*/
public Boolean isLowerCase()
{
java.lang.String exitID = "Character>>isLowerCase";
Frame f0 = new Frame(exitID);
return (Boolean)this.isLowercase();
}
/**
* @return
*/
public Boolean isUppercase()
{
java.lang.String exitID = "Character>>isUppercase";
Frame f0 = new Frame(exitID);
return (Boolean)Character.type().isUppercase(this);
}
/**
* @return
*/
public Boolean isUpperCase()
{
java.lang.String exitID = "Character>>isUpperCase";
Frame f0 = new Frame(exitID);
return (Boolean)this.isUppercase();
}
/**
* @return
*/
public Boolean isVowel()
{
java.lang.String exitID = "Character>>isVowel";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(VowelList.contains(this.asString()));
}
/**
* @return
*/
@Override public Boolean isLiteral()
{
java.lang.String exitID = "Character>>isLiteral";
Frame f0 = new Frame(exitID);
return (Boolean)True.literal();
}
/**
* @return
*/
@Override public Boolean isCharacter()
{
java.lang.String exitID = "Character>>isCharacter";
Frame f0 = new Frame(exitID);
return (Boolean)True.literal();
}
}