ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | Protected Static Fields | Protected Fields | Protected Methods | List of all members
FormatterPythonStyle Class Reference
Inheritance diagram for FormatterPythonStyle:
[legend]
Collaboration diagram for FormatterPythonStyle:
[legend]

Class Description


Implements a Formatter according to the formatting standards of the Python language.

Note
Inherited, public fields of parent class FormatterStdImpl provide important possibilities for changing the formatting behavior of instances of this class. Therefore, do not forget to consult the parent classes documentation.

In general, the original Python specification is covered quite well. However, there are some differences, some things are not possible (considering python being a scripting language) but then there are also found some very helpful extensions to that standard. Instead of repeating a complete documentation, please refer to the Python Documentation as the foundation and then take note of the following list of differences, extensions and general hints:

Public Fields

AutoSizes sizes = new AutoSizes()
 
- Public Fields inherited from FormatterStdImpl
NumberFormat alternativeNumberFormat = new NumberFormat()
 
SimpleDateFormat dateTimeFormat = new SimpleDateFormat("", Locale.ROOT)
 
NumberFormat defaultNumberFormat = new NumberFormat()
 
boolean writeALibErrorReports = true
 
boolean writeErrorsToTargetString = true
 
- Public Fields inherited from Formatter
Formatter next
 

Public Methods

 FormatterPythonStyle ()
 
void reset ()
 
- Public Methods inherited from FormatterStdImpl
 FormatterStdImpl (String formatterClassName)
 
void cloneSettings (FormatterStdImpl reference)
 
- Public Methods inherited from Formatter
void format (AString target, ArrayList< Object > args)
 
void format (AString target, Object[] args)
 

Protected Static Fields

static char[] constColonAndClosingBracket = ":}".toCharArray()
 
- Protected Static Fields inherited from Formatter
static Formatter defaultFormatter = null
 
static ThreadLock defaultFormatterLock = new ThreadLock()
 

Protected Fields

Substring conversion = new Substring()
 
Substring phaExtConversion = new Substring()
 
int phaExtDefaultPrecision
 
int phaExtPrecision
 
- Protected Fields inherited from FormatterStdImpl
int argsConsumed
 
AString fieldBuffer = new AString()
 
String formatterName
 
int nextAutoIdx
 
int pargOffset
 
ArrayList< Object > parguments
 
Substring parser = new Substring()
 
Substring pformatString = new Substring()
 
Alignment phaAlignment
 
boolean phaAlignmentSpecified
 
Object phaArgument
 
int phaArgumentIdx
 
int phaCutContent
 
char phaFillChar
 
Substring phaFormatSpec = new Substring()
 
boolean phaIsPercentage
 
NumberFormat phaNF = new NumberFormat()
 
int phaPreviousArgumentIdx
 
boolean phaSignPaddingMode
 
PHType phaType
 
char phaTypeCode
 
int phaWidth
 
boolean phaWriteBinOctHexPrefix
 
AString ptargetString
 
int targetStringStartLength
 
- Protected Fields inherited from Formatter
ArrayList< Object > boxes
 
Substring lamFormatString = new Substring()
 

Protected Methods

boolean checkStdFieldAgainstArgument ()
 
void construct ()
 
int findPlaceholder ()
 
void initializeFormat ()
 
boolean parsePlaceholder ()
 
boolean parseStdFormatSpec ()
 
boolean preAndPostProcess (int startIdx, AString target)
 
void replaceEscapeSequences (int startIdx)
 
void resetPHAs ()
 
- Protected Methods inherited from FormatterStdImpl
void errorFormatString (String msg)
 
int format (AString targetString, Substring formatString, ArrayList< Object > arguments, int argOffset)
 
boolean setArgument (int pos, boolean countStartsWith_1)
 
boolean writeCustomFormat ()
 
void writeStdArgument ()
 

Additional Inherited Members

- Public Static Methods inherited from Formatter
static Formatter acquireDefault ()
 
static void releaseDefault ()
 
- Package Access Fields inherited from FormatterStdImpl
Date tmpDate = new Date()
 
- Package Access Methods inherited from FormatterStdImpl
long getIntegral ()
 
boolean isIntegral ()
 

Constructor & Destructor Documentation

◆ FormatterPythonStyle()


Constructs this formatter. Inherited field defaultNumberFormat is initialized to meet the formatting defaults of Java.

Member Function Documentation

◆ checkStdFieldAgainstArgument()

boolean checkStdFieldAgainstArgument ( )
protected

Makes some attribute adjustments and invokes standard implementation

Returns
true if OK, false if replacement should be aborted.

Reimplemented from FormatterStdImpl.

◆ construct()

void construct ( )
protected

Constructor helper method.

◆ findPlaceholder()

int findPlaceholder ( )
protected

Searches for '{' which is not '{{'.

Returns
The index found, -1 if not found.

Reimplemented from FormatterStdImpl.

◆ initializeFormat()

void initializeFormat ( )
protected

Sets the actual auto tab stop index to 0.

Reimplemented from Formatter.

◆ parsePlaceholder()

boolean parsePlaceholder ( )
protected

Parses placeholder field in python notation. The portion format_spec is not parsed but stored in member Formatter.phaFormatSpec.

Returns
true on success, false on errors.

Reimplemented from FormatterStdImpl.

◆ parseStdFormatSpec()

boolean parseStdFormatSpec ( )
protected

Parses the format specification for standard types as specified in "Format Specification Mini Language".

Returns
true on success, false on errors.

Reimplemented from FormatterStdImpl.

◆ preAndPostProcess()

boolean preAndPostProcess ( int  startIdx,
AString  target 
)
protected

Processes "conversions" which are specified with '!'.

Parameters
startIdxThe int of the start of the field written in ptargetString. -1 indicates pre-phase.
targetThe target string, only if different from field ptargetString, which indicates intermediate phase.
Returns
false, if the placeholder should be skipped (nothing is written for it). true otherwise.

Reimplemented from FormatterStdImpl.

◆ replaceEscapeSequences()

void replaceEscapeSequences ( int  startIdx)
protected

Implementation of abstract method.
Replaces "{{" with "{" and "}}" with "}". In addition applies AString.escape on target which replaces standard codes like "\\n", "\\r" or "\\t" with corresponding ascii codes.

Parameters
startIdxThe start of the region to replace

Reimplemented from FormatterStdImpl.

◆ reset()

void reset ( )

Resets sizes.

Reimplemented from Formatter.

◆ resetPHAs()

void resetPHAs ( )
protected

Invokes parent implementation and then applies some changes to reflect what is defined as default in the Python string format specification.

Reimplemented from FormatterStdImpl.

Member Data Documentation

◆ constColonAndClosingBracket

char [] constColonAndClosingBracket = ":}".toCharArray()
staticprotected

Constant string array

◆ conversion

Substring conversion = new Substring()
protected

Reused object used to parse phaExtConversion in method preAndPostProcess.

◆ phaExtConversion

Substring phaExtConversion = new Substring()
protected

The portion of the replacement field that represents the conversion specification. This specification is given at the beginning of the replacement field, starting with '!'.

◆ phaExtDefaultPrecision

int phaExtDefaultPrecision
protected

The default precision if not given. This is set to 6 in resetPHAs, but is changed when specific.

◆ phaExtPrecision

int phaExtPrecision
protected

The value read from the precision field. This is set to -1 in resetPHAs.

◆ sizes

AutoSizes sizes = new AutoSizes()

Storage of sizes for auto-tabulator feature {!ATab} and auto field width feature {!AWidth}


The documentation for this class was generated from the following file: