foray-commit Mailing List for FOray (Page 3)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2025-06-10 08:57:10
|
Revision: 13828
http://sourceforge.net/p/foray/code/13828
Author: victormote
Date: 2025-06-10 08:57:07 +0000 (Tue, 10 Jun 2025)
Log Message:
-----------
Remove conversions back to ASCII hex as unnecessary.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java 2025-06-07 14:01:42 UTC (rev 13827)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java 2025-06-10 08:57:07 UTC (rev 13828)
@@ -37,6 +37,8 @@
/**
* Filter that converts the content of an "IBM PC Format" PostScript Type 1 font (typically having the extension .pfb)
* into input suitable for a PostScript interpreter.
+ * The only real purpose of this filter is to parse the six bytes at the beginning of each segment of the file, so that
+ * they can be tracked and properly ignored.
* @see "Supporting Downloadable PostScript Language Fonts, Technical Note #5040"
*/
public class PfbFontDecodeFilter extends DataInputStream {
@@ -62,10 +64,6 @@
/** The offset to the beginning of the next segment. */
private int nextSegmentOffset = 0;
- /** The next nibble to be returned. This should always be -1, except when we have only returned the first nibble
- * of the last byte read. */
- private int nextNibble = -1;
-
/**
* Constructor.
* @param inputStream The underlying input stream.
@@ -76,13 +74,6 @@
@Override
public int read() throws IOException {
- if (this.nextNibble != -1) {
- /* We need to return the second nibble of the last byte read. */
- final int returnValue = this.nextNibble;
- this.nextNibble = -1;
- return returnValue;
- }
-
int intRead = in.read();
this.offset ++;
if (intRead < 0) {
@@ -91,6 +82,12 @@
}
if (this.offset - 1 == this.nextSegmentOffset) {
+ if (this.currentSegmentType == SEGMENT_TYPE_END_OF_FILE) {
+ /* We are immediately after the last segment. This should probably never happen, as we should have read
+ * a -1 above before we get here. */
+ in.close();
+ return -1;
+ }
/* We are at the beginning of a segment. */
if (intRead != START_OF_SEGMENT_MARKER) {
throw new IOException("Unexpected value at start of segment: 0x" +
@@ -98,27 +95,15 @@
}
this.currentSegmentType = in.read();
this.offset ++;
- if (this.currentSegmentType == SEGMENT_TYPE_END_OF_FILE) {
- in.close();
- return -1;
- }
/* Read the size of the segment. Reverse the bytes, as they are little-endian. */
final int segmentSize = Integer.reverseBytes(readInt());
this.offset += Integer.BYTES;
- this.nextSegmentOffset = this.offset + segmentSize;
+ this.nextSegmentOffset = this.offset + segmentSize - 1;
intRead = in.read();
}
- if (this.currentSegmentType == SEGMENT_TYPE_ASCII_TEXT) {
- return intRead;
- }
- if (this.currentSegmentType == SEGMENT_TYPE_BINARY_DATA) {
- this.nextNibble = ByteUtils.toHexCharLow((byte) intRead);
- return ByteUtils.toHexCharHigh((byte) intRead);
- }
-
- return -1;
+ return intRead;
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-07 14:01:45
|
Revision: 13827
http://sourceforge.net/p/foray/code/13827
Author: victormote
Date: 2025-06-07 14:01:42 +0000 (Sat, 07 Jun 2025)
Log Message:
-----------
Clean up no-longer-needed code.
Modified Paths:
--------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java
trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/AsciiHexDecodeFilterTests.java
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java 2025-06-07 13:17:39 UTC (rev 13826)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java 2025-06-07 14:01:42 UTC (rev 13827)
@@ -29,9 +29,7 @@
package org.foray.ps.filter;
import org.foray.primitive.StringUtils;
-import org.foray.primitive.sequence.ByteArrayBuilder;
-import org.axsl.constants.MeasurementConstants;
import org.axsl.constants.PrimitiveConstants;
import org.axsl.ps.PsFilterType;
@@ -41,7 +39,6 @@
/**
* Decoding filter for {@link PsFilterType#ASCII_HEX}.
- * Static methods are available for processing entire arrays.
* @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class AsciiHexDecodeFilter extends PsDecodeFilter4a {
@@ -49,31 +46,9 @@
/** End-of-data marker specified in the PostScript standard. */
public static final byte END_OF_DATA = 0x3E;
-// /** Stores exactly one meaningful leftover byte from the end of the last chunk processed that needs to be included
-// * in the next chunk to be processed. */
-// private byte leftoverByte = -1;
-//
-// /** For decoding, stores the location of the end-of-data marker. If -1, then eod has not yet been found. */
-// private int eodLocation = -1;
-//
-// /** Indicates whether the underlying input stream has been read yet. */
-// private boolean inputRead = false;
-//
-// /** Buffer of bytes that have been read from our underlying input stream but not yet decoded. */
-// private byte[] encodedBuffer;
-//
-// /** Buffer of bytes that have been decoded but not yet read by our client.*/
-// private byte[] decodedBuffer = new byte[MeasurementConstants.BYTES_PER_KILOBYTE];
-//
-// /** The starting index in decodedBuffer which is active. */
-// private int decodedIndex = 0;
-
/** Flag signalling completions. */
private boolean doneReading = false;
- /** TODO: Remove this temporary kludge. */
- private ByteArrayBuilder builder = new ByteArrayBuilder(MeasurementConstants.BYTES_PER_KILOBYTE * 2);
-
/**
* Constructor.
* @param inputStream The underlying input stream from which the encoded data should be read.
@@ -115,166 +90,7 @@
final byte decodedByte = StringUtils.asciiHexBytesToHex(byte1, byte2);
final int decodedInt = decodedByte & PrimitiveConstants.MAX_8_BIT_UNSIGNED_INT;
-
-// /* TODO: Remove this temporary kludge. */
-// if (decodedInt > -1) {
-// this.builder.append(decodedByte);
-// }
-
return decodedInt;
-
-
-// if (! this.inputRead) {
-// readInput();
-// this.inputRead = true;
-// }
-// /* If we have a byte in our decoded buffer, return it. */
-// if (this.decodedIndex < this.decodedBuffer.length) {
-// this.decodedIndex ++;
-// return this.decodedBuffer[this.decodedIndex - 1];
-// } else {
-// /* Indicate end-of-file. */
-// return -1;
-// }
}
-// /**
-// * Reads all of the underlying input and decodes it.
-// * @throws IOException For errors reading the input.
-// */
-// public void readInput() throws IOException {
-// final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// boolean doneReading = false;
-// while (! doneReading) {
-// final int inputByte = in.read();
-// if (inputByte < 0) {
-// doneReading = true;
-// }
-// baos.write(inputByte);
-// }
-// this.encodedBuffer = baos.toByteArray();
-// /* Otherwise we need to read from our source and decode some data. */
-// if (this.eodLocation > -1) {
-// return;
-// }
-// // Save the leftover byte
-// final byte savedLeftoverByte = this.leftoverByte;
-// int dataBytes = 0;
-// if (this.leftoverByte > -1) {
-// dataBytes++;
-// }
-// /*
-// * Scan the input, looking for end-of-data character & counting data
-// * bytes.
-// */
-// for (int i = 0; i < this.encodedBuffer.length && this.eodLocation < 0; i ++) {
-// if (this.encodedBuffer[i] == AsciiHexEncodeFilter.END_OF_DATA) {
-// this.eodLocation = i;
-// break;
-// }
-// if (! AsciiHexEncodeFilter.isAsciiHexWhitespace(this.encodedBuffer[i])) {
-// dataBytes ++;
-// }
-// }
-// int outputLength = dataBytes / 2; // truncate any remainder
-//
-// this.leftoverByte = -1;
-// if (dataBytes % 2 != 0) {
-// // If we are at the end-of-data, make room for the zero-filled byte
-// if (this.eodLocation > -1) {
-// outputLength += 1;
-// } else {
-// // Otherwise, count backward from the end of the array to find
-// // the leftovers
-// for (int i = this.encodedBuffer.length - 1; i > 0 && this.leftoverByte < 1; i--) {
-// if (! AsciiHexEncodeFilter.isAsciiHexWhitespace(this.encodedBuffer[i])) {
-// this.leftoverByte = this.encodedBuffer[i];
-// }
-// }
-// }
-// }
-// this.decodedBuffer = decodeArray(savedLeftoverByte, this.encodedBuffer,
-// this.encodedBuffer.length,
-// outputLength);
-// }
-
- /**
- * Decodes the input array, starting at byte 0 and extending to byte inputLength, and returns the output in a byte
- * array.
- * Handles possible leftover byte from a previous run.
- * @param leftoverByte The byte, if any, leftover from processing a previous chunk.
- * If there is no leftover byte, enter any negative number to skip processing.
- * @param input The input byte array. This first byte of this array must never be the second byte of a 2-byte
- * "word".
- * @param inputLength The last byte of the input byte array that should be examined for purposes of creating the
- * output byte array.
- * @param outputLength The size that the output array should be.
- * @return The output byte array.
- * It should be approximately 1/2 the size of the input array (whitespace characters in the input are ignored, so it
- * may be somewhat less than 1/2 the size of the input array).
- * Please note that this routine ignores any incomplete "words" in the input.
- * @throws IOException If the input array contains invalid ASCIIHex characters.
- */
- public static byte[] decodeArray(final byte leftoverByte, final byte[] input, final int inputLength,
- final int outputLength) {
- if (outputLength < 1) {
- return null;
- }
- if (inputLength < 1) {
- return null;
- }
- final byte[] output = new byte[outputLength];
- int outputIndex = 0;
- byte byte1 = 0x00;
- byte byte2 = 0x00;
- boolean byte1Found = false;
- boolean byte2Found = false;
- // If there is a valid leftoverByte, start the processing with it.
- if (leftoverByte > -1
- && ! AsciiHexEncodeFilter.isAsciiHexWhitespace(leftoverByte)) {
- byte1 = leftoverByte;
- byte1Found = true;
- }
- for (int i = 0; i < inputLength && outputIndex < outputLength; i ++) {
- if (input[i] == AsciiHexEncodeFilter.END_OF_DATA) {
- break;
- }
- // Skip whitespace
- if (AsciiHexEncodeFilter.isAsciiHexWhitespace(input[i])) {
- continue;
- }
- if (byte1Found && byte2Found) {
- output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1, byte2);
- outputIndex ++;
- byte1Found = false;
- byte2Found = false;
- }
- if (byte1Found) {
- byte2 = input[i];
- byte2Found = true;
- } else {
- byte1 = input[i];
- byte1Found = true;
- }
- }
- if (outputIndex < outputLength) {
- if (byte1Found) {
- if (! byte2Found) {
- byte2 = 0x00;
- }
- output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1, byte2);
- }
- }
- return output;
- }
-
- /**
- * Returns the decoded buffer.
- * @return The decoded buffer.
- */
- public byte[] getDecodedBuffer() {
-// return this.decodedBuffer;
- return this.builder.toArray();
- }
-
}
Modified: trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/AsciiHexDecodeFilterTests.java
===================================================================
--- trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/AsciiHexDecodeFilterTests.java 2025-06-07 13:17:39 UTC (rev 13826)
+++ trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/AsciiHexDecodeFilterTests.java 2025-06-07 14:01:42 UTC (rev 13827)
@@ -54,13 +54,17 @@
private static final byte[] EXPECTED = {(byte) 0xfa, 0x44, 0x4f, 0x27, 0x1e, (byte) 0xd9};
/**
- * Test of {@link AsciiHexDecodeFilter#decodeArray(byte, byte[], int, int)}.
+ * Test of decoding an array.
* @throws IOException Not expected here.
*/
@Test
public void testDecodeArray() throws IOException {
- final byte[] actual =
- AsciiHexDecodeFilter.decodeArray((byte) -1, INPUT.getBytes("US-ASCII"), INPUT.length(), 6);
+ final byte[] inputBytes = INPUT.getBytes("US-ASCII");
+ final ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
+ final AsciiHexDecodeFilter filter = new AsciiHexDecodeFilter(bais);
+ final ByteArrayBuilder builder = new ByteArrayBuilder();
+ builder.append(filter);
+ final byte[] actual = builder.toArray();
assertArrayEquals(EXPECTED, actual);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-07 13:17:42
|
Revision: 13826
http://sourceforge.net/p/foray/code/13826
Author: victormote
Date: 2025-06-07 13:17:39 +0000 (Sat, 07 Jun 2025)
Log Message:
-----------
Rough-in a decode filter for PFB Type 1 fonts.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-06-06 22:45:40 UTC (rev 13825)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-06-07 13:17:39 UTC (rev 13826)
@@ -31,6 +31,7 @@
import org.foray.font.ttf.TableDirectory;
import org.foray.font.ttf.TrueTypeCollection;
import org.foray.font.ttf.TrueTypeSingle;
+import org.foray.font.type1.PfbFontDecodeFilter;
import org.foray.font.type1.Type1FontParser;
import org.foray.font.type1.Type1FontParserPfa;
import org.foray.font.type1.Type1FontParserPfb;
@@ -134,7 +135,7 @@
// Type1 Font (PC or PFB Format)
this.randomInput.seek(0);
unsignedByte = this.randomInput.readUnsignedByte();
- if (unsignedByte == Type1FontParserPfb.START_OF_SEGMENT_MARKER) {
+ if (unsignedByte == PfbFontDecodeFilter.START_OF_SEGMENT_MARKER) {
this.randomInput.seek(Type1FontParserPfb.SIZE_SEGMENT_HEADER);
tag = this.randomInput.readStringASCII(FontParser.TYPE_1_HEADER_1.length());
if (tag.startsWith(FontParser.TYPE_1_HEADER_2)
Added: trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java 2025-06-07 13:17:39 UTC (rev 13826)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.type1;
+
+import org.foray.primitive.ByteUtils;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Filter that converts the content of an "IBM PC Format" PostScript Type 1 font (typically having the extension .pfb)
+ * into input suitable for a PostScript interpreter.
+ * @see "Supporting Downloadable PostScript Language Fonts, Technical Note #5040"
+ */
+public class PfbFontDecodeFilter extends DataInputStream {
+
+ /** Constant for the value of the first byte of a new segment, {@value}. */
+ public static final short START_OF_SEGMENT_MARKER = 0x80;
+
+ /** Indicator for start of an ASCII text segment. */
+ public static final int SEGMENT_TYPE_ASCII_TEXT = 1;
+
+ /** Indicator for start of a binary data segment. */
+ public static final int SEGMENT_TYPE_BINARY_DATA = 2;
+
+ /** Indicator for the end of file. */
+ public static final int SEGMENT_TYPE_END_OF_FILE = 3;
+
+ /** The index to the next byte to be read. Also equals the number of bytes read. */
+ private int offset;
+
+ /** Indicator for the current segment type. */
+ private int currentSegmentType;
+
+ /** The offset to the beginning of the next segment. */
+ private int nextSegmentOffset = 0;
+
+ /** The next nibble to be returned. This should always be -1, except when we have only returned the first nibble
+ * of the last byte read. */
+ private int nextNibble = -1;
+
+ /**
+ * Constructor.
+ * @param inputStream The underlying input stream.
+ */
+ public PfbFontDecodeFilter(final InputStream inputStream) {
+ super(inputStream);
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (this.nextNibble != -1) {
+ /* We need to return the second nibble of the last byte read. */
+ final int returnValue = this.nextNibble;
+ this.nextNibble = -1;
+ return returnValue;
+ }
+
+ int intRead = in.read();
+ this.offset ++;
+ if (intRead < 0) {
+ in.close();
+ return -1;
+ }
+
+ if (this.offset - 1 == this.nextSegmentOffset) {
+ /* We are at the beginning of a segment. */
+ if (intRead != START_OF_SEGMENT_MARKER) {
+ throw new IOException("Unexpected value at start of segment: 0x" +
+ ByteUtils.toHexString((byte) intRead));
+ }
+ this.currentSegmentType = in.read();
+ this.offset ++;
+ if (this.currentSegmentType == SEGMENT_TYPE_END_OF_FILE) {
+ in.close();
+ return -1;
+ }
+ /* Read the size of the segment. Reverse the bytes, as they are little-endian. */
+ final int segmentSize = Integer.reverseBytes(readInt());
+ this.offset += Integer.BYTES;
+ this.nextSegmentOffset = this.offset + segmentSize;
+
+ intRead = in.read();
+ }
+
+ if (this.currentSegmentType == SEGMENT_TYPE_ASCII_TEXT) {
+ return intRead;
+ }
+ if (this.currentSegmentType == SEGMENT_TYPE_BINARY_DATA) {
+ this.nextNibble = ByteUtils.toHexCharLow((byte) intRead);
+ return ByteUtils.toHexCharHigh((byte) intRead);
+ }
+
+ return -1;
+ }
+
+ @Override
+ public synchronized void mark(final int readlimit) {
+ in.mark(readlimit);
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ in.reset();
+ }
+
+ @Override
+ public boolean markSupported() {
+ return in.markSupported();
+ }
+
+ @Override
+ public void close() throws IOException {
+ in.close();
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/type1/PfbFontDecodeFilter.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java 2025-06-06 22:45:40 UTC (rev 13825)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java 2025-06-07 13:17:39 UTC (rev 13826)
@@ -29,6 +29,7 @@
package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
+import org.foray.font.format.FontFileFormat;
import org.foray.font.format.FontParser;
import org.foray.font.format.FontParserClient;
@@ -170,7 +171,17 @@
*/
private PsFontDictionary parseFontDictionary() {
/* TODO: Find a cleaner way to get this input stream. */
- final InputStream input = new ByteArrayInputStream(this.parser.getRandomInput().getByteSequence().toArray());
+ final InputStream rawInput = new ByteArrayInputStream(this.parser.getRandomInput().getByteSequence().toArray());
+
+ /* If this is an IBM PC Format PFB file, wrap it in a decoder. */
+ InputStream input = rawInput;
+ if (this.parser.getFileFormat() == FontFileFormat.TYPE1_PFB) {
+ input = new PfbFontDecodeFilter(rawInput);
+ }
+
+
+
+
final PsServer psServer = getParserClient().getPsServer();
PsInterpreter interpreter = null;
final PsSystemDict systemDict = psServer.getReadOnlySystemDict();
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java 2025-06-06 22:45:40 UTC (rev 13825)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java 2025-06-07 13:17:39 UTC (rev 13826)
@@ -42,21 +42,6 @@
* of the font contents. */
public static final byte DEFAULT_LINE_LENGTH = 72;
- /** Constant indicating the segment number for the ASCII text portion of
- * the file. */
- public static final byte SEGMENT_ASCII_TEXT = 1;
-
- /** Constant indicating the segment number for the binary portion of the
- * file. */
- public static final byte SEGMENT_BINARY_DATA = 2;
-
- /** Constant indicating the segment number for the end-of-file segment of
- * the file. */
- public static final byte SEGMENT_END_OF_FILE = 3;
-
- /** Constant for the value of the first byte of a new segment. */
- public static final short START_OF_SEGMENT_MARKER = 128;
-
/** Constant for the size of the segment header, in bytes. */
public static final byte SIZE_SEGMENT_HEADER = 6;
@@ -96,7 +81,7 @@
getRandomInput().seek(offset);
// Make sure it is the beginning of a segment
final int segmentHead = getRandomInput().readUnsignedByte();
- if (segmentHead != Type1FontParserPfb.START_OF_SEGMENT_MARKER) {
+ if (segmentHead != PfbFontDecodeFilter.START_OF_SEGMENT_MARKER) {
throw new IOException("Invalid PFB file. Expected 0x80 at start "
+ "of segment index " + segmentIndex + ".");
}
@@ -107,13 +92,13 @@
// Validate the segment type
if (segmentIndex == Type1Font.QTY_SEGMENTS) {
/* Make sure it is an end-of-file segment. */
- if (segmentType != Type1FontParserPfb.SEGMENT_END_OF_FILE) {
+ if (segmentType != PfbFontDecodeFilter.SEGMENT_TYPE_END_OF_FILE) {
invalidPFBSegmentTypeException();
}
} else {
/* Make sure it is a data segment. */
- if (segmentType != Type1FontParserPfb.SEGMENT_ASCII_TEXT
- && segmentType != Type1FontParserPfb.SEGMENT_BINARY_DATA) {
+ if (segmentType != PfbFontDecodeFilter.SEGMENT_TYPE_ASCII_TEXT
+ && segmentType != PfbFontDecodeFilter.SEGMENT_TYPE_BINARY_DATA) {
invalidPFBSegmentTypeException();
}
segmentSize = (int) getRandomInput().readUnsignedIntLoHi();
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-06-06 22:45:40 UTC (rev 13825)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-06-07 13:17:39 UTC (rev 13826)
@@ -99,6 +99,7 @@
final PsFontPrivateDictionary privateDict = fontDict.getPrivateDictionary();
assertNotNull(privateDict);
+ assertEquals(new BigDecimal("94"), privateDict.getStdVw());
final PsCharStringsDictionary charStringsDict = fontDict.getCharStringsDictionary();
assertNotNull(charStringsDict);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-06 22:45:43
|
Revision: 13825
http://sourceforge.net/p/foray/code/13825
Author: victormote
Date: 2025-06-06 22:45:40 +0000 (Fri, 06 Jun 2025)
Log Message:
-----------
Fixes to "closefile" especially as implemented in eexec.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-06 12:42:07 UTC (rev 13824)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-06 22:45:40 UTC (rev 13825)
@@ -93,4 +93,9 @@
return this.inputStream.markSupported();
}
+ @Override
+ public void close() throws IOException {
+ this.inputStream.close();
+ }
+
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-06 12:42:07 UTC (rev 13824)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-06 22:45:40 UTC (rev 13825)
@@ -2138,11 +2138,12 @@
* @throws PsOperatorException For any PostScript error.
*/
private void closefile() throws PsOperatorException {
+ /* Not sure whether this applies to a PsString, but we assume for now that it does. */
final PsObject object = popOperand(PsOperator.CLOSEFILE);
- if (! (object instanceof PsFile)) {
+ if (! (object instanceof PsInputStream)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.CLOSEFILE);
}
- final PsFile file = (PsFile) object;
+ final PsInputStream file = (PsInputStream) object;
try {
file.close();
} catch (final IOException e) {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-06-06 12:42:07 UTC (rev 13824)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-06-06 22:45:40 UTC (rev 13825)
@@ -79,6 +79,9 @@
/** The count of bytes read, mostly to discard the random bytes added during encryption. */
private int bytesRead = 0;
+ /** Indicates whether this filter is still open. */
+ private boolean isOpen = true;
+
/**
* Constructor.
* @param inputStream The inputStream to be decoded.
@@ -103,6 +106,9 @@
* @throws IOException For IO errors reading the underlying stream.
*/
private int internalRead() throws IOException {
+ if (! this.isOpen) {
+ return -1;
+ }
final int cipherText = in.read();
if (cipherText < 0) {
return -1;
@@ -161,4 +167,9 @@
return "N/A";
}
+ @Override
+ public void close() {
+ this.isOpen = false;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-06 12:42:14
|
Revision: 13824
http://sourceforge.net/p/foray/code/13824
Author: victormote
Date: 2025-06-06 12:42:07 +0000 (Fri, 06 Jun 2025)
Log Message:
-----------
Convert String to PsName for dictionary keys. This gets Type1 font parsing working again, so reactivate related test.
Modified Paths:
--------------
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-06-06 11:59:19 UTC (rev 13823)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-06-06 12:42:07 UTC (rev 13824)
@@ -41,7 +41,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -59,7 +58,6 @@
* @throws IOException For errors reading the test file.
*/
@Test
- @Disabled
public void testParse() throws FontException, IOException {
final String path = "/source-utah.edu/utopia-1.0/putr.pfa";
final InputStream inputStream = getClass().getResourceAsStream(path);
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java 2025-06-06 11:59:19 UTC (rev 13823)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java 2025-06-06 12:42:07 UTC (rev 13824)
@@ -153,10 +153,11 @@
/**
* Return the value for a given key.
- * @param key The key whose value should be retrieved.
+ * @param stringKey The key whose value should be retrieved.
* @return The value.
*/
- public PsObject getItem(final String key) {
+ public PsObject getItem(final String stringKey) {
+ final PsName key = new PsName(stringKey, false, false);
for (PsObject currentKey : this.dictionary.keySet()) {
if (currentKey.equals(key)) {
return this.dictionary.get(currentKey);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-06 11:59:22
|
Revision: 13823
http://sourceforge.net/p/foray/code/13823
Author: victormote
Date: 2025-06-06 11:59:19 +0000 (Fri, 06 Jun 2025)
Log Message:
-----------
Fix problems in currentfile() and readstring() related to casting of input streams.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-06 00:28:54 UTC (rev 13822)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-06 11:59:19 UTC (rev 13823)
@@ -1793,19 +1793,27 @@
*/
private void currentfile() {
/* The "currentfile" doc says this operator returns "the topmost file object on the execution stack."
- * TODO: This method is therefore possibly wrong in two ways.
- * 1. We understand "file" to mean "stream" which could include a PsString.
- * 2. We are not sure what to do if the topmost item is not a "file" or other stream. Should the stack be
- * traversed until one is found? Should non-file items on the stack be popped and then pushed to the operand
- * stack? */
- final PsObject psObject = getInterpreter().getExecutionStack().peek();
- if (psObject instanceof PsInputStream) {
- final PsInputStream psInputStream = (PsInputStream) psObject;
- pushOperand(psInputStream);
- } else {
- /* Per "currentfile" doc, this never occurs during execution of ordinary user programs. */
- pushOperand(new PsString(""));
+ * We have made two assumptions related to this.
+ * 1. We understand this to mean that there may be other things on the execution stack (such as procedures) that
+ * should be ignored.
+ * In other words, the stack needs to be traversed until a "file" is found.
+ * We are pretty confident that this understanding is correct, practice showing that there are sometimes
+ * procedures at the top of the stack when "currentfile" is called.
+ * Since "currentfile" is frequently followed by "readstring" and a procedure could not be read from a
+ * procedure for "readsting" purposes, we conclude that traversing the stack is correct.
+ * 2. We understand "file" to mean "stream" which could include a PsString.
+ * We are much less confident that this is correct, but have found no practical evidence either way .*/
+ final PsExecutionStack executionStack = getInterpreter().getExecutionStack();
+ for (int index = 0; index < executionStack.size(); index ++) {
+ final PsObject psObject = executionStack.peek(index);
+ if (psObject instanceof PsInputStream) {
+ final PsInputStream psInputStream = (PsInputStream) psObject;
+ pushOperand(psInputStream);
+ return;
+ }
}
+ /* Per "currentfile" doc, this never occurs during execution of ordinary user programs. */
+ pushOperand(new PsString(""));
}
/**
@@ -1920,17 +1928,17 @@
@SuppressWarnings("resource")
final PsString string = (PsString) object;
object = popOperand(PsOperator.READSTRING);
- if (! (object instanceof PsFile)) {
+ if (! (object instanceof PsInputStream)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.READSTRING);
}
@SuppressWarnings("resource")
- final PsFile file = (PsFile) object;
+ final PsInputStream file = (PsInputStream) object;
final ByteArrayBuilder builder = new ByteArrayBuilder(string.getValue().length());
builder.append(string.getValue());
int charsRead = 0;
- for (int i = 0; i < string.getValue().length() && file.isOpen(); i++) {
+ for (int i = 0; i < string.getValue().length(); i++) {
try {
builder.setByteAt(i, (byte) file.read());
} catch (final IOException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-06 00:28:57
|
Revision: 13822
http://sourceforge.net/p/foray/code/13822
Author: victormote
Date: 2025-06-06 00:28:54 +0000 (Fri, 06 Jun 2025)
Log Message:
-----------
Save the output from eexec for debugging reference.
Modified Paths:
--------------
trunk/foray/foray-00-dev/config/checkstyle/checkstyle-suppressions.xml
trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java
Added Paths:
-----------
trunk/foray/foray-ps-data/src/test/ps/
trunk/foray/foray-ps-data/src/test/ps/00-readme.txt
trunk/foray/foray-ps-data/src/test/ps/putr_eexec.ps
Modified: trunk/foray/foray-00-dev/config/checkstyle/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/foray-00-dev/config/checkstyle/checkstyle-suppressions.xml 2025-06-05 23:53:25 UTC (rev 13821)
+++ trunk/foray/foray-00-dev/config/checkstyle/checkstyle-suppressions.xml 2025-06-06 00:28:54 UTC (rev 13822)
@@ -38,6 +38,7 @@
<suppress checks=".*" files="src.test.resources.*"/>
<suppress checks=".*" files="src.main.data.*"/>
<suppress checks=".*" files="src.main.archive.*"/>
+ <suppress checks=".*" files="src.test.ps.*"/>
<!-- Permanently suppress some checks in data transfer interfaces. -->
<suppress checks="LeftCurly" files="src.main.java.org.foray.fontParse.ttf.handler.*"/>
Modified: trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java
===================================================================
--- trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java 2025-06-05 23:53:25 UTC (rev 13821)
+++ trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java 2025-06-06 00:28:54 UTC (rev 13822)
@@ -83,9 +83,10 @@
/* Store the decoded bytes for testing. */
/* See {@link AsciiHexDecodeFilter#testWithFontInput()} for size computation. */
- final ByteArrayBuilder builder = new ByteArrayBuilder(34932);
+ final int expectedLength = ((qtyBytes - qtyLineFeeds) / 2) - EexecDecodeFilter.EEXEC_RANDOM_BYTES;
+ assertEquals(34_928, expectedLength);
+ final ByteArrayBuilder builder = new ByteArrayBuilder(expectedLength);
builder.append(filter);
- final int expectedLength = ((qtyBytes - qtyLineFeeds) / 2) - EexecDecodeFilter.EEXEC_RANDOM_BYTES;
assertEquals(expectedLength, builder.length());
final byte[] plaintextBytes = builder.toArray();
@@ -101,10 +102,15 @@
assertEquals("/Ccedilla 57 -| ", lines.get(760).substring(0, 16));
assertEquals("mark currentfile closefile", lines.get(776));
- /* Uncomment the following lines to spit out the content to system out. */
+ /* Uncomment the following lines to spit out the content to a local file. That file is maintained in the
+ * repository to assist with debugging. */
+// final File dumpFile = new File("src/test/ps/putr_eexec.ps");
+// dumpFile.createNewFile();
+// final PrintStream out = new PrintStream(dumpFile);
// for (String line : lines) {
-// System.out.println(line);
+// out.println(line);
// }
+// out.close();
}
}
Added: trunk/foray/foray-ps-data/src/test/ps/00-readme.txt
===================================================================
--- trunk/foray/foray-ps-data/src/test/ps/00-readme.txt (rev 0)
+++ trunk/foray/foray-ps-data/src/test/ps/00-readme.txt 2025-06-06 00:28:54 UTC (rev 13822)
@@ -0,0 +1,8 @@
+Explanation of the file(s) in this directory:
+1. putr_eexec.ps is the output from src/test/java,
+ class org.foray.ps.filter.EexecDecodeFilterTests, test test01.
+ It is intended as an example of eexec content, and to assist with debugging
+ of the PostScript interpreter.
+ To regenerate it, see commented lines a the very end of that test.
+
+# Last line of memo.
Property changes on: trunk/foray/foray-ps-data/src/test/ps/00-readme.txt
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-ps-data/src/test/ps/putr_eexec.ps
===================================================================
--- trunk/foray/foray-ps-data/src/test/ps/putr_eexec.ps (rev 0)
+++ trunk/foray/foray-ps-data/src/test/ps/putr_eexec.ps 2025-06-06 00:28:54 UTC (rev 13822)
@@ -0,0 +1,777 @@
+dup /Private 17 dict dup begin
+/-|{string currentfile exch readstring pop}executeonly def
+/|-{noaccess def}executeonly def
+/|{noaccess put}executeonly def
+/BlueValues [ -15 0 692 707 490 502 668 680 742 742 ] |-
+/OtherBlues [ 265 272 -242 -230 ] |-
+/BlueScale 0.0437917 def
+/MinFeature{16 16} |-
+/StdHW [35] |-
+/StdVW [94] |-
+/ForceBold false def
+/password 5839 def
+/Erode{
+11.5 dup 3 -1 roll 0.1 mul exch 0.5 sub mul cvi sub dup mul
+94 0 dtransform dup mul exch dup mul add
+le{pop pop 1.0 1.0}{pop pop 0.0 1.5}ifelse}def
+/UniqueID 36552 def
+/OtherSubrs
+[ {} {} {}
+{
+systemdict /internaldict known not
+{pop 3}
+{1183615869 systemdict /internaldict get exec
+dup /startlock known
+{/startlock get exec}
+{dup /strtlck known
+{/strtlck get exec}
+{pop 3}
+ifelse}
+ifelse}
+ifelse
+} executeonly
+]|-
+/Subrs 349 array
+dup 0 15 -| �=t*�������� |
+dup 1 9 -| �=t*��d |
+dup 2 9 -| �=t*��x% |
+dup 3 5 -| �=t*� |
+dup 4 12 -| �=t*n��@ 6 |
+dup 5 17 -| �=t*��
+�)"���l�t |
+dup 6 17 -| �=t*�+dup 7 27 -| �=t*|H���A��$����������� |
+dup 8 27 -| �=t*|H���A��$������Gk�_3! |
+dup 9 19 -| �=t*�3���L3*M|�� |
+dup 10 23 -| �=t*�3���L+� \Qb[�PhDd |
+dup 11 19 -| �=t*�3���L+� ]�~e |
+dup 12 23 -| �=t*�3���L+� \Qb[��8� |
+dup 13 23 -| �=t*�9
+���Z.<]DM[�2*� |
+dup 14 23 -| �=t*SL��2�2 �+dup 15 23 -| �=t*SL��2�2 �+dup 16 17 -| �=t*������{���� |
+dup 17 17 -| �=t*+B\M�Pv&*� |
+dup 18 20 -| �=t*�'��}�������� |
+dup 19 20 -| �=t*�_�� �������� |
+dup 20 20 -| �=t*�@���Q��+iJ�} |
+dup 21 20 -| �=t*�@���Q��+hp~{� |
+dup 22 16 -| �=t*�Ffy���s� |
+dup 23 23 -| �=t*)Z�m1mW+dup 24 23 -| �=t*�o�*A$����P�� I |
+dup 25 13 -| �=t*MaG���^�� |
+dup 26 14 -| �=t*�{)u�! |
+dup 27 24 -| �=t*@�����b{�)*{�Q�H��T |
+dup 28 21 -| �=t*f�0:�i*nm�I�G� |
+dup 29 17 -| �=t*�
+h�+�e�Z� |
+dup 30 12 -| �=t*���GZ�� |
+dup 31 23 -| �=t*me�����4���q$G;��� |
+dup 32 22 -| �=t*me��� y��A�a�4�� |
+dup 33 23 -| �=t*me��� y�������D���� |
+dup 34 20 -| �=t*��!�|
+<{��X7�r |
+dup 35 16 -| �=t*��!�|
+��{+dup 36 16 -| �=t*me��&�J *� |
+dup 37 20 -| �=t*me��&�Jue��4�h, |
+dup 38 18 -| �=t*���Le3�;Y��� |
+dup 39 11 -| �=t*���� |
+dup 40 15 -| �=t*���@���k�� |
+dup 41 18 -| �=t*���Le39����� |
+dup 42 23 -| �=t*���]p����+dup 43 24 -| �=t*��!��N�.8��#:��� |
+dup 44 24 -| �=t*��!�+��5� |
+dup 45 19 -| �=t*me���cm���I� |
+dup 46 11 -| �=t*me���� |
+dup 47 14 -| �=t*me��XR%�� |
+dup 48 23 -| �=t*me�����I���=���l�u |
+dup 49 24 -| �=t*me�����I���=���b�?f |
+dup 50 22 -| �=t*me����Y�;�����\�(� |
+dup 51 23 -| �=t*me����Y�;�����R���� |
+dup 52 15 -| �=t*15y�z^� o |
+dup 53 15 -| �=t*15v��(��zY |
+dup 54 15 -| �=t*�Y�B�$Mon |
+dup 55 26 -| �=t*�Y�B�,�7��e�,���f� |
+dup 56 15 -| �=t*���'�*B*�w |
+dup 57 17 -| �=t*q$<��P���� |
+dup 58 17 -| �=t*��qf��=?��: |
+dup 59 20 -| �=t*�W�+Y+~01]�� |
+dup 60 17 -| �=t*�!��{������ |
+dup 61 12 -| �=t*06UYL� |
+dup 62 12 -| �=t*�!��-x, |
+dup 63 15 -| �=t*A�������r |
+dup 64 15 -| �=t*A��������' |
+dup 65 13 -| �=t*�D���> |
+dup 66 23 -| �=t*Y�7�_'��80��*�FL |
+dup 67 23 -| �=t*Y�7�_'L^��y8�$�/ |
+dup 68 23 -| �=t*����(hO����bcv�Z |
+dup 69 23 -| �=t*�����fB�nJ��� |
+dup 70 15 -| �=t*�g�����1wZ |
+dup 71 15 -| �=t*&[t����5 |
+dup 72 15 -| �=t*.`�L��V��j� |
+dup 73 16 -| �=t*^�x����NP��q |
+dup 74 17 -| �=t*O���=%?�cz� |
+dup 75 22 -| �=t*�ol�V+dup 76 23 -| �=t*�5�(L�M]�D5��L��� |
+dup 77 23 -| �=t*^�x�K� j��j<#��3��� |
+dup 78 15 -| �=t*^�x����C�o� |
+dup 79 15 -| �=t*^�x����^�8� |
+dup 80 15 -| �=t*��
+���$op |
+dup 81 15 -| �=t*��L6��\� |
+dup 82 19 -| �=t*Y�7��1��9���R |
+dup 83 15 -| �=t*Y�7��1b&,{ |
+dup 84 31 -| �=t*�&�?q��bs��
+|�_���V&��E |
+dup 85 16 -| �=t*�uD
+������ |
+dup 86 16 -| �=t*�F�>���@l� |
+dup 87 17 -| �=t*p�uF�e)q�i |
+dup 88 16 -| �=t*�uD&Z�?� |
+dup 89 21 -| �=t*�
+h~�YR6����+dup 90 21 -| �=t*i����77�Nk�F�o� |
+dup 91 16 -| �=t*�
+hr��)�p |
+dup 92 17 -| �=t*�.�3��P��� |
+dup 93 23 -| �=t*�.�F������q��� |
+dup 94 15 -| �=t*=}2�������� |
+dup 95 14 -| �=t*����L��� |
+dup 96 11 -| �=t*i�%J��� |
+dup 97 11 -| �=t*\����� |
+dup 98 20 -| �=t*i�%Fm��}���� |
+dup 99 15 -| �=t*SYlz{<���� |
+dup 100 11 -| �=t*E����C� |
+dup 101 11 -| �=t*SYlz�e� |
+dup 102 13 -| �=t*�&���+�� |
+dup 103 13 -| �=t*�&���� |
+dup 104 14 -| �=t*i��C����$ |
+dup 105 14 -| �=t*�+dup 106 23 -| �=t*X}yd��������g�U�� |
+dup 107 19 -| �=t*X}yd�+�6�*j |
+dup 108 16 -| �=t*�|��������� |
+dup 109 16 -| �=t*�|������f� |
+dup 110 19 -| �=t*P���P���B�V
+� |
+dup 111 23 -| �=t*P���P����a6j��}/1c |
+dup 112 17 -| �=t*"G�����3��f� |
+dup 113 17 -| �=t*?�A>,����� |
+dup 114 20 -| �=t*qhu���R�8�%i�)� |
+dup 115 20 -| �=t*p�������86��/% |
+dup 116 16 -| �=t*���+�Rw%��� |
+dup 117 20 -| �=t*���#f����\. |
+dup 118 13 -| �=t*����HV�� |
+dup 119 25 -| �=t*�����/��4��
+pL������ |
+dup 120 22 -| �=t*~�;��l�}��+dup 121 13 -| �=t*���k�%�� |
+dup 122 13 -| �=t*���Ekw�J |
+dup 123 13 -| �=t*���EE��? |
+dup 124 17 -| �=t*���Ekw��+o�] |
+dup 125 12 -| �=t*��g���` |
+dup 126 12 -| �=t*��g�{�� |
+dup 127 19 -| �=t*�2��!�]�2��|� |
+dup 128 23 -| �=t*�5�����D8� 7[]t�U� |
+dup 129 15 -| �=t*�5�����|&� |
+dup 130 19 -| �=t*�2���vf;I��� |
+dup 131 11 -| �=t*�2���; |
+dup 132 15 -| �=t*�2���]�D |
+dup 133 20 -| �=t*���A�����_�� |
+dup 134 20 -| �=t*���A���1��J4_,� |
+dup 135 14 -| �=t*bB���^���? |
+dup 136 18 -| �=t*bB��H$+��[��� |
+dup 137 24 -| �=t*��!���
+�>��v��;�$� |
+dup 138 11 -| �=t*^�x���s |
+dup 139 19 -| �=t*���(>�u�t}�F� |
+dup 140 23 -| �=t*^�x�������e���!� |
+dup 141 23 -| �=t*^�x�����R'U���0��~ |
+dup 142 20 -| �=t*_�<�rn���.Z��� |
+dup 143 32 -| �=t*��.�BV3�W52B�����0c�3U�c |
+dup 144 20 -| �=t*_��A��;�B�����W |
+dup 145 19 -| �=t*Y�7��1b&,�}>*l |
+dup 146 12 -| �=t*��i�� |
+dup 147 12 -| �=t*��kc � |
+dup 148 12 -| �=t*��P�� |
+dup 149 19 -| �=t*���@���k�b/J�q |
+dup 150 12 -| �=t*���|�� |
+dup 151 12 -| �=t*���V�} |
+dup 152 12 -| �=t*���w��1 |
+dup 153 12 -| �=t*�~����p |
+dup 154 12 -| �=t*�~�e� |
+dup 155 16 -| �=t*
+X���0�N+dup 156 12 -| �=t*�p�
+� |
+dup 157 12 -| �=t*�p�u �A |
+dup 158 28 -| �=t*9��,)�|�������,�jt� |
+dup 159 12 -| �=t*������ |
+dup 160 12 -| �=t*���?�e� |
+dup 161 12 -| �=t*���#<�\ |
+dup 162 39 -| �=t*�fu�P�]��W��0��00uFw���9��X |
+dup 163 39 -| �=t*�fu�P�]��W��0��&���t��)21�Kb |
+dup 164 19 -| �=t*15v��(��z���Z |
+dup 165 26 -| �=t*}�7S�PP|�t�LUu����� |
+dup 166 12 -| �=t*�fS�uY |
+dup 167 12 -| �=t*�fS���\ |
+dup 168 16 -| �=t*�fS�u�b�0 |
+dup 169 12 -| �=t*��E�Q� |
+dup 170 12 -| �=t*��ky�� |
+dup 171 16 -| �=t*��E�Q n��� |
+dup 172 25 -| �=t*�.�?.;�n7������@� |
+dup 173 26 -| �=t*�.�F������q���� � |
+dup 174 26 -| �=t*�_{}�kG#�����a��&^� |
+dup 175 27 -| �=t*���7U���s�NK����:��� |
+dup 176 16 -| �=t*�fR�r���Pp� |
+dup 177 16 -| �=t*�0C�g�1X��g |
+dup 178 27 -| �=t*|a��v<�yr����~+��>d#� |
+dup 179 19 -| �=t*m2�k�8oO ���! |
+dup 180 19 -| �=t*m2�k�8oO �-��� |
+dup 181 21 -| �=t*�
+h�+�e�Z?�-� |
+dup 182 16 -| �=t*���GZ�G���1 |
+dup 183 16 -| �=t*���G5@%I- |
+dup 184 16 -| �=t*���G5@���� |
+dup 185 23 -| �=t*=}2�������B�PY��� |
+dup 186 15 -| �=t*q�����E |
+dup 187 20 -| �=t*����n�wF��+dup 188 16 -| �=t*���GZ�G>d� |
+dup 189 27 -| �=t*�
+h������%�/����o�� |
+dup 190 27 -| �=t*�
+h������9������JU� |
+dup 191 19 -| �=t*A������������ |
+dup 192 21 -| �=t*b��d=�\�� ��� |
+dup 193 21 -| �=t*Pj�x�:���S�'i�F |
+dup 194 21 -| �=t*Pj�x�:�����4%b� |
+dup 195 21 -| �=t*b��d=�\���f��c� |
+dup 196 20 -| �=t*b��r�`�:��`�T |
+dup 197 20 -| �=t*b��r�`�:���u� |
+dup 198 20 -| �=t*b��r�`��u1�T* |
+dup 199 20 -| �=t*Pj�x�Y�C�">�(�� |
+dup 200 20 -| �=t*Pj�x�Y�C�u$^��( |
+dup 201 20 -| �=t*b��r�`�:����p |
+dup 202 25 -| �=t*"����51<b�[�%d�R |
+dup 203 17 -| �=t*"����5M�� |
+dup 204 24 -| �=t*"����51:�&�J=2� |
+dup 205 22 -| �=t*Y�7��1��9�����~� |
+dup 206 20 -| �=t*
+�����M�[�
+.EU@ |
+dup 207 19 -| �=t*Y�8n�`��6D�7^ |
+dup 208 20 -| �=t*?�1����[�imA��� |
+dup 209 11 -| �=t*y����� |
+dup 210 22 -| �=t*��:���Q�!i���� |
+dup 211 24 -| �=t*4b�� A��d�\H� T���� |
+dup 212 15 -| �=t*����wg{�0_ |
+dup 213 15 -| �=t*�����E< |
+dup 214 19 -| �=t*��
+���$o�>�� |
+dup 215 23 -| �=t*��L6��\v2�= |
+dup 216 12 -| �=t*�0C��7A |
+dup 217 12 -| �=t*�0C��N3 |
+dup 218 16 -| �=t*�0C��7��? |
+dup 219 33 -| �=t*me��}��wn�m���Q�(�r ���J�m�(� |
+dup 220 107 -| �=t*���$H0��rd����<6���~���]R���J-�W���He��E��@1rMR�
+��l���s�����^c��E�P6�,�9�� ����#�^o��]��� |
+dup 221 36 -| �=t*���!�~��.�9���hW�S�D�1���N��; |
+dup 222 94 -| �=t*p�#���������h��d��*k�4�.hA�<��"�F"���_�R��r~��;��,���@mW�M������*M�zF�`�>8�@r��{�(� |
+dup 223 39 -| �=t*q��E�!Y�P$,%_k��gM�]��+�b+I |
+dup 224 66 -| �=t*:a7�F�f��.w���;��Z��y���������]5%A
+�4L;�a�-����P��Q�N |
+dup 225 26 -| �=t*J�P��bP�k6l�^�i�� |
+dup 226 44 -| �=t*p�.��������%���=J����[�������:INt� |
+dup 227 24 -| �=t*�������H���Cw����� |
+dup 228 47 -| �=t*���B�S<�3��N�bS/�� ����$r���V)=�x ��k! |
+dup 229 144 -| �=t*�_��E�1
+w�.r�1!=�����N���["XE�����L���x]�p�koh����N0��D�"ChV(��s0��%�G��*~��y�U�_�����bS7���\k�]���2�M�zU���U�UAwT��4��t�)`���� |
+dup 230 17 -| �=t*��Z��0x"�I� |
+dup 231 15 -| �=t*���o����jf |
+dup 232 54 -| �=t*sj�]�|'�U�MdW}"z���q���G��"���8��*Z'_��sI� |
+dup 233 35 -| �=t*sk�`��+"�8��|��m$n�+6����� |
+dup 234 96 -| ��k��f$*A&�6��� �nP�L<v] ��|�=����C��m4����
+�H'�B�4���X5���/}���6�u�=����>����6.��mjoI |
+dup 235 11 -| ��k������Y |
+dup 236 36 -| ��k��Tj�v.
+@��6�k�6[�����O;�� |
+dup 237 35 -| ��k��R�1Ds3J��E�?tOZ�������o���;��� |
+dup 238 39 -| ��k������tQw���PW��C��^0���"t�}��U�
+�� |
+dup 239 36 -| ��k��G_��w����.5&
+�Sh@�/��+��)�0� |
+dup 240 17 -| ��k�
+<4�/6����]( |
+dup 241 35 -| ��k���a�L5�����;pZKF<$������]�� |
+dup 242 108 -| ��k��g�u6�1����J*�����<���-��$�ATRF���(=@e����$��(�]�Hf�o���0b�j{W��i*n��c8��� ���];"���P�!C�� |
+dup 243 28 -| ��k���l����OCa�1�rF��X��c^& |
+dup 244 14 -| ��k���U
+�zf�p |
+dup 245 36 -| ��k�������
+{����5�H�EiC�8#��X |
+dup 246 17 -| ��k���/�z_;��|u� |
+dup 247 27 -| ��k��/�G��T$Y�4�A ��t���. |
+dup 248 54 -| ��k�\d9/81���R�� &/tT-��7�!\%`AMx�>B�q��k���3Rg�h� |
+dup 249 54 -| ��k��Kp��l�/�2g����v7n^����ar��V��1P*?L.���9y� |
+dup 250 19 -| ��k�����I%�
+�hB� |
+dup 251 15 -| ��k���ff)�X�^� |
+dup 252 16 -| ��k�����)o�+�w |
+dup 253 88 -| ��k�����[_/�|�+��������Jx��L���o��g�B���d���X�Mz���T����B�W���"�h|q�/��$
+�k |
+dup 254 87 -| ��k���,+dup 255 83 -| ��k��$���,�a[��nq���*t�
+�S�KI3�Pyt9�H|��oN�Q�
+�Z��.N�S��N����4��+dup 256 81 -| ��k������n�S�����.K���?��{���H��C0K���_����K|Hi�
+������Lx�tH�� K{�l��!� |
+dup 257 16 -| ��k���4ur���}u� |
+dup 258 26 -| ��k�����^�����Pd2Hn�'z�� |
+dup 259 43 -| ��k����� SUD�������� 0�$���W����������k� |
+dup 260 56 -| ��k���{Bq������&��,�~A�'�Y���+xu���d���UC.Iw����� |
+dup 261 19 -| ��k���F�����N���� |
+dup 262 41 -| ��k���i��G_��������K�d,X�R�m�_������k |
+dup 263 19 -| ��k��Ol�dz���Etp� |
+dup 264 41 -| ��k���n\.���"�~k���l@�tBB��M���@Q�y�`��� |
+dup 265 24 -| ��k���+G/�ulv |
+dup 266 39 -| ��k�!���)�S�R�f��������T�D��q����i |
+dup 267 11 -| ��k����~�� |
+dup 268 15 -| ��k���fiQo����� |
+dup 269 28 -| ��k��a`TUh��6���b\���c��� |
+dup 270 40 -| ��k��s�E��+dup 271 61 -| ��k�����jz��XO�o^�+<�l�zbO�D
+ Y���V��Yz��E�y�`�D��h�[� |
+dup 272 36 -| ��k����6�g�v.Mf�r��\�Zq��a�
+tG|7 |
+dup 273 64 -| ��k���%��������&wB�%�'��+dup 274 63 -| ��k���/���*2��]�-"���;xa�N�c7*�e�]*����:������q����C� |
+dup 275 14 -| ��k������J*\� |
+dup 276 61 -| ��k��_��Y5�:H,q��t��{�<z/�o��yx#+dup 277 34 -| ��k���`h�x��+������n��w/�IiUA��� |
+dup 278 59 -| ��k�"������Hb�"��U,�B�1��7i@�}k��F�*��������|O3���3��J� |
+dup 279 25 -| ��k���{�W$�:���:m�l��� |
+dup 280 18 -| ��k���n�� ��=��� |
+dup 281 33 -| ��k��.3p�J�����3�EK�p�L!q���)� |
+dup 282 12 -| ��k����-�� |
+dup 283 20 -| ��k�����|�����Y)z+� |
+dup 284 54 -| ��k�Xn�m��Gp]�����h)��;���c�E:��#S
+���J
+5���PO |
+dup 285 24 -| ��k���n n�91�)+��P���� |
+dup 286 53 -| ��k��L�{'G-����A%����0p~�Z��u)B��Ll8qo]����L{�*Y
+ |
+dup 287 17 -| ��k����
+��)�� |
+dup 288 18 -| ��k��-���$����� |
+dup 289 30 -| ��k�����9��pl<?�N��J_���W�S |
+dup 290 33 -| ��k���sO�b�z��9�X����Q~��}��^r |
+dup 291 51 -| ��k��D��wL�r���
+��]�~&�sxE+n�Y��Y�+K��*�6�,��k |
+dup 292 14 -| ��k���T-�|?n�� |
+dup 293 28 -| ��k���F�i3[*���X��y4�e�Z��| |
+dup 294 28 -| ��k��M3���\N;]�_Z6����x~�� |
+dup 295 47 -| ��k��oh�)��,�3x�����a���%��^��+dup 296 46 -| ��k�������@���&����89!6vK�������|����W&MM |
+dup 297 27 -| ��k���`i;��d�=���H(�#mC�o |
+dup 298 14 -| ��k�����>�A!�R |
+dup 299 26 -| ��k���+dup 300 25 -| ��k�������
+$�z���pR=�K
+� |
+dup 301 19 -| ��k����g2(L�N�T� |
+dup 302 19 -| ��k�����)����_T�� |
+dup 303 40 -| ��k���b�`X�X \�����d�<�N��#�+dup 304 39 -| ��k�?��?-�e�SiY��=�v����__#)��s/�? |
+dup 305 39 -| ��k�����Tp����I�F[:��nh��;�~ ��@� �ak |
+dup 306 38 -| ��k���
+E�����W��y�p��� �?�t|d.��� |
+dup 307 23 -| ��k�����`��O��;x��V�go |
+dup 308 10 -| ��k����~3� |
+dup 309 36 -| ��k�&o�����c�.+?�B����L#=� |
+dup 310 15 -| ��k�������^^��} |
+dup 311 35 -| ��k��Y&3��U�,,��!�����WU�Z��q�5�pS� |
+dup 312 35 -| ��k���+uN�.�l�g��������D�*����� |
+dup 313 21 -| ��k���/�g)x�q�]B�3� |
+dup 314 21 -| ��k��a`TUh������k� �� |
+dup 315 21 -| ��k���\���q��s�Ol�� |
+dup 316 33 -| ��k��5p��<&���X���_3<�*�'����� |
+dup 317 13 -| ��k����y�J�� |
+dup 318 12 -| ��k��fY�E� |
+dup 319 12 -| ��k�a���tT |
+dup 320 16 -| ��k�qs�<�pjT�4� |
+dup 321 16 -| ��k�����)n5��� |
+dup 322 32 -| ��k����#����-�8�~� o`+����jy� |
+dup 323 32 -| ��k������?A��?\�Gu��#6���D�v |
+dup 324 12 -| ��k��-�K>�. |
+dup 325 20 -| ��k��Je�D���HE;l� |
+dup 326 30 -| ��k���d����D����mHi����`� |
+dup 327 30 -| ��k��g�
+15�*��!������1D35 |
+dup 328 29 -| ��k�X���r������N���_���\�w |
+dup 329 29 -| ��k���/�>Q�(i9�"VhYo.N����C |
+dup 330 29 -| ��k���l����L���E���V����� |
+dup 331 29 -| ��k�����3�&���g
+�@���&����u� |
+dup 332 29 -| ��k������I�3�3&�G:�@i#s��p�K |
+dup 333 29 -| ��k��38
+%D�(�����"p��(X� |
+dup 334 12 -| ��k��O�y��� |
+dup 335 12 -| ��k�����O; |
+dup 336 28 -| ��k��o��j�N���7�N�����(�� |
+dup 337 9 -| ��k���}A |
+dup 338 27 -| ��k�W�=���JW���0k���Ik>p� |
+dup 339 27 -| ��k��������_����)��>$d��� |
+dup 340 27 -| ��k���U
+S��?%LH����fxr�� |
+dup 341 26 -| ��k�/e�.:���h�
+�$���9m��� |
+dup 342 14 -| ��k�.���e�l�[ |
+dup 343 17 -| ��k���9�<��h�)�P� |
+dup 344 17 -| ��k��"<`w�]6?��W |
+dup 345 26 -| ��k����qV�������}�����"� |
+dup 346 26 -| ��k�������&�Y�cV������� |
+dup 347 25 -| ��k�5��F�"�;��=P�E�!w�P� |
+dup 348 25 -| ��k��Z��3 ��+�1�yM��]�� |
+|-
+2 index /CharStrings 229 dict dup begin
+/space 9 -| �[���9y |-
+/exclam 52 -| �[�8�(��/�~C����k1�br����d$��R��i����v����1X��� |-
+/quotedbl 30 -| �[������F��l�
+|�e��CfU�2n�P |-
+/numbersign 129 -| �[�W�o2�+/dollar 157 -| �[�H!�Q�8�a�?������Y"��i3Ww+/percent 72 -| �[� }v��f��0��W�y�����9����|-��h��d�[co$c����w��4��icB�E��Q7g�`v� |-
+/ampersand 213 -| �[����m����*W9�_�k�D(k�����e�S]�����e��z�����2����87��z<v� o����W�{{���yS��J��:������z"6��� �L�}Nj;�t"���Nj�O����L��p��]��%g�^�%��������'&P�P���}�|�xG)%��A+/quoteright 23 -| �[��~<����>'|��� |-
+/parenleft 65 -| �[��dd%��lpr����R3H����v!�G�)�U eVb�\b��iO�k.�b#
+���,�p�{��� |-
+/parenright 67 -| �[�`'�V�g(����D������uIj�R-�W�s���e����}z�!]��j��A��m��l�a�� |-
+/asterisk 194 -| �[�!F�N��Z�
+�mk�����W\K��C�JE*R�:�^b���z�`u�:�nd�Q���<��,�����9����c�`�2�����������6+/plus 58 -| �[���y��U�F5��b_��\��;F�5M�=���eX$Z�Ts�w�����WM) |-
+/comma 24 -| �[���-����e_U��t�}��� |-
+/hyphen 28 -| �[�M�+/period 23 -| �[��_M��+/slash 36 -| �[��V����T������B�I�%�~iL�w<�� |-
+/zero 92 -| �[����8��e�����I���1N�u��t�}(�h������7�d���G@�N\�k�2%�j��Qe10�{Ow�k���W�h����� |-
+/one 85 -| �[�JF�_�r2��%yId��5 �H�(3�l��n%�)p;�O����}�OC7�!����B2�'���pX����&�����a� |-
+/two 111 -| �[��-4.�o��]q�����������;��n!���J�bC��HH����n��@+\����<K��������������R�d�����UG0�<c�����G�� ?�� |-
+/three 148 -| �[��Dp��)�1��oe]2�7#]��t0��^Nw�d��?xHrlQm�4��R�kL����R�Z^|������J@;���7\� uv���S
+��)U�*?�<��o�`�(�8�E�Y�������F�
+a�h��w7�
+hsL�hy� |-
+/four 105 -| �[���XC���������x0L �]�q+/five 120 -| �[�1���P9
+����R�>L�#K:@Ro�(��@��b����!�;��� ��]ruH_�����`��JP?���j��*�������D|&wm�� ���4Z����I����dU5�����Q |-
+/six 138 -| �[�H!�Io�Rr��\Y\3H��X����=i�\��d�E;eDwe��N���GN���z�B l��SVY�Vy���Z�L����j`i�,Cm����"Hj�|6b���j���H�x�����k���bL^��zK��0 |-
+/seven 97 -| �[����1y�.����������L�=���q+/eight 137 -| �[��F�Md�l3Pmf��V�yQ���T�u�}� � � I�4�T�K\��<��&����f+/nine 157 -| �[��������10=/A-)���f�= O����Q�T�sO6���d�����0m�I�T\:�Cih�/�*k��2�V���'��^[�\�7J$��^���AS�����Q�E{cZ��!����B�{�7��+/colon 33 -| �[��_M��+/semicolon 30 -| �[���-�o~��������m/4.+[�-� |-
+/less 45 -| �[��!�Z��:c~')2s
+�������z����0�� |-
+/equal 45 -| �[�����\�]F%����z2�7�R�3�1%w Gv�4�Da> |-
+/greater 45 -| �[��!���w�Pm��=0���4�~2a���t���C��W_O�� |-
+/question 144 -| �[���t��y)���t"+/at 212 -| �[��^H�����'�0sn��+���#�5��l�t���%�M��jkU����u�m�$�������jN�n�_3��>t�@X��!�����uY���zY������D����
+�<��3&�=p/��������#�����v��3\�:5��o����zhS�NdU�FX�M+�{X
+����Z���e�����:7��,U�2�|�LU��W |-
+/A 12 -| �[@�-��� |-
+/B 123 -| �[�~��9��*� �V?�o���J����Z�H��WX������MaX-�r,?�CC��$�0�H��E��'�B;1#3����
+�2{���vL'�����W�)|�y������S�8���>piw�"�9 |-
+/C 44 -| �[��r�������+/D 38 -| �[�~a@� ���j�-��O F�-������!���j#� |-
+/E 18 -| �[�>t\����q
+��� |-
+/F 103 -| �[��O%p[O&��/���Bo��:�c���J~����*�i�Mi���;���zj�t�0;�E�7g$� ����,�GL�2u�V :������Btz�d/�o�4��� |-
+/G 135 -| �[��/�&��l�Ru�_���\�`�\i�y�H�y��@#n,��f{�*�sG<5S]i�+�4{Mn@��H�3d�� S�Gt���kH��"���,�,�H9��m�� |-
+/H 68 -| �[�~L$��������+9��/��oN<���^��+�����
+�E�X�U�����I�6|�L����� |-
+/I 20 -| �[�pEr����7�}t>� |-
+/J 65 -| �[��8T8bes%���k�+/K 104 -| �[�~�+/L 47 -| �[�+/M 108 -| �[���'m"��X��?IA�����A���[��F�4~�]��U�b��w�b��d�5��M�T�&����t��4���{j;��A�A�R��I��_D�����%ByP���� |-
+/N 22 -| �[���v�E �rUB|@�a3) |-
+/O 15 -| �[���M���C��3 |-
+/P 100 -| �[� Db���-��=����yA��������NmA�^z��R�sf�"���\�m���FAAS�{}�JL��h�_�QF{�c�G�l� ��-��=�[7+/Q 96 -| �[���M�
+;��"+���u�|���UVP��������I����������j#�Lw���-����Rr�p�V�c�R����U2���nTe� |-
+/R 111 -| �[�~�Zr\�s�>�jeEp�R)M������`1v~�~*^�)�t���R�W���@��Qc�w'�L���(���5�n�{���a|�b.�#��{>B�0L���0���p^� |-
+/S 18 -| �[�!������=��Z0� |-
+/T 91 -| �[�f��/W�/�X�������.�
+�q06!��o�>2:��
+{���V��~g>(���a{��E�����:��u*��@��>z(�78�W��� |-
+/U 15 -| �[����yp/� |-
+/V 121 -| �[W���y�]^e��<~SY�����L#���s���M����t����h��0��un�4]�g��m��K����f�3��?��y�F4vz�PB�q�d.��^k]���\��w��_<�!
+�3 |-
+/W 165 -| �[P)������H>2)!���Y�����t�^���j,<��6���<�����V�kU�����_Z��f��Y��/�<��X�O�9�L�m�����R~���`O���UK! �fy�����_����>�p��~}�����C�#��4y`�sj7�D[t�X����R`J |-
+/X 175 -| �[VP�\G��m�����U'�������n�#%)s�V���������obp�Y��[&���� t8�9V����`@�~5U�I������5�sm>L����_�^�y���\�2{}a��r�M�%4�m{���@�V�c�����P���h�� #�E�u���qU����mW� |-
+/Y 12 -| �[QY/]KT#� |-
+/Z 19 -| �[��r-�u����c^�[ |-
+/bracketleft 53 -| �[�R�������/{�-���)�F������5 X�����1A}%�E��� |-
+/backslash 34 -| �[�n�+(�"�&�<"��"���Jk��� �I�� |-
+/bracketright 51 -| �[�q��3_Xs��e
+�m�.�*?�'$�oB������L��V�,L��� |-
+/asciicircum 50 -| �[���.�@pY��/�WuA���V�I�}���������[���x��m��@ |-
+/underscore 30 -| �[��IB[�H*}t�Quv
+�&��=k�" |-
+/quoteleft 25 -| �[��~u�6���� �Y#En7oGq |-
+/a 15 -| �[���c&=���� |-
+/b 107 -| �[��������Q%V�-/��tjg�kJ��S+/�9�8���������)� |-
+/c 94 -| �[������������_Uh�������w��Pt`9:�=Hd)<���fq���`�(���}���w�Ni�{&����`J���J����.�� 9� |-
+/d 127 -| �[���B��Y��tI��9#=5�����*�8��y�|�|����z[��+������7WMZ����Gc��v`���Ip]/����.N�����D#Ke��U��='p\~�uk��N��,�D�?�~�V |-
+/e 15 -| �[���m; $B��7 |-
+/f 97 -| �[����d������4uI-<#T���y�s��S[#+�����p��T�n��Wn_�uL����U�
+�����B%j:������N��ap� |-
+/g 203 -| �[��<�k���&,�t��q������O�~7J����E+/h 128 -| ��~\�����n �V�����{��+����B@3mCU5�utmZ7g��MPx@%Et�{E������.���PM��g�%6�Q
+�����|�:G�i>��������=*�E5g���nG{���,�F� |-
+/i 46 -| ��u�Uzr����*��FR�/�@�b>d�_Y���C�Gp������� |-
+/j 99 -| ����D�an�U�<5�����}e��Hf|�"��:M�>�7�� A�Z�j��
+,a�w�����Z/$X[��7���?����
+o�lI� |-
+/k 123 -| ��A��kp�h��^�OWb-���O�&����<�q����N/e�O������/�j5Cq�����T8��+/l 34 -| ��A���
+�T��+@�$�c�� �� |-
+/m 124 -| ��u�b�����D�g{�W*6/`<@�f�]�?��J�X,��]4����w��r4��E���4]|�}("a7����c���!���*�*��)a�|�1�^�{��Ym�a�!��L�;>���� k�o |-
+/n 15 -| ��u���%�Z�s |-
+/o 15 -| ��b��R'�+/p 83 -| ��z�����=1{n��d�f���e�D]{c�Da���^E:k�"�dX�8�K==]�cZ.��?�{Z/~�3��a���L�#�) |-
+/q 142 -| ��b��{��z����b���Q.�W?�T��b�����0���Z>^����:��2����7p��]�Z��Z�\X+/r 93 -| ��u����u'��$x���2X���K��'����}b�����gc�x�*U`i��Q,�AX0��� bQ �gm���\����+/s 31 -| ��dUMl6v���$�ob�E-�o��cf�� |-
+/t 78 -| ��tcs��@�/C�Z���B�\��Y���F�'���u�"��D?]��Z��CR>���h���{�)��x%}��� |-
+/u 19 -| ��{� (���'��nb� |-
+/v 132 -| ��R������R����j����|1G���F� 3��"\��*{��n[�^J0d��`���Y�t������m[Sz %w[Ip�}��b��V���0?�&�&��!����MD��9qM@����� ���e�EP�I% |-
+/w 164 -| ��W�}P��-F��yn��+.x��jxtXf�S�S~�����[�����UOn��x(j[��C�G�����Cx8�}v�<����E!�e��2�.i���s7��+v����a�=�/�=����:�
+��h�$t�����4���Y\�I
+����~�{�4�� |-
+/x 180 -| ��R�]���N���j������`���I�q>������r��NG�$G|�D���t�%}(����L��6�(�8��^���������Bq�����G��I��e�k�C\9+��|
+36���3d�
+����@'����qV������7����c�Bj1 |-
+/y 12 -| ��X������0 |-
+/z 36 -| ��@]�[$�4�;-�/�n+/braceleft 115 -| ����>���r�[��3�
+.m�6�%���\7�����������j�Q�^PM���-��G])�h��Y��@1i�K��x�.Rh������`�n��'��E���$
+��O�� |-
+/bar 28 -| �����ICo����{�8-���?���� |-
+/braceright 117 -| ��k�(xH���^nq����j$'�y�d+���OB����C��.��,j�5o�XD���Xg~Z�O2��c�U�G��i?��f�,�������$�mEc��3 �����=��mqAb- |-
+/asciitilde 85 -| ��
+������^ m���13.���b�I���S�J�������Yh���y��[��>JQ�z��G����b(N�l\��
+�Gg�' |-
+/exclamdown 72 -| ��'`�ij~��E�TH0��LW��p���38����s1e� 1���eV^��P����t_:���c"�� |-
+/cent 129 -| ��nE��R(�^D|}r���X���a���>Yi>^�3/4f��+�,�6Q�60��1�����t_�����]�h�e3���h��*2�*����{)����C�R�?����+�� FD?����5��� |-
+/sterling 142 -| ��x5��H+j)E�|��,��b�+����6����C0� �[tA���]��;�<L �����Z���p���c�>���9���U9=i�'��z5�#�� �J��i���������9L�u�ng�V�����$����Y�5 |-
+/fraction 32 -| ��%�&I���e]�z�����Mo_�IR���� |-
+/yen 192 -| ��W�������+>��uO��;��\g��Sn�
+p��6{�+���a+/florin 153 -| ��W������VvY��iz�����M���sfR��^���LW ���
+yt0r+`#� |-
+/section 200 -| ��g�T�l�+�+�����Pn���&�T�aZ�� �_�b^��5:N���di(�
+�!�TS[T~�� @�����~E����d�r�vK�dF���~?�c��<�kW�I�y�������vs/q)0 |-
+/currency 189 -| ��z����x����DT��ez�+�fb������bS��]��C\k��Y�|k$��.���H�����j�<��b������c��6�+���fH^_�k'�k���&S0�L6S���
+f��I~����%:�"���`�Q����,,4�x� ���ki�nc6������WGmg.�+/quotesingle 23 -| ��6bh<o/[cd �f+m� |-
+/quotedblleft 36 -| ��
+~�0��>N�T�3g����=53J�q��� |-
+/guillemotleft 35 -| ��j{t�EQ��2+P���� �a�[���* |-
+/guilsinglleft 24 -| ��jt6��,,j��g��mG�9�J |-
+/guilsinglright 27 -| ��jt6��_�,���SL��Q� ]� |-
+/fi 132 -| ��w`$����s�dvP:/R�����3�e�B
+/���u0��x�&z|��mNL>�����W��m�+�
+/��*�����]��'i����KdT�-�������S����`,��GE�sJ�D{���6��V���� |-
+/fl 88 -| ��w`$����^Z�A�o�|��Uv.T9�!��:� ��Y#�X1BP������%z�R�=�����Qm�O���+/endash 28 -| ��Ul
+���F;�������� �o�$ |-
+/dagger 127 -| ��f��
+���y:�@A)��0���4%��a����8��qS����~��o,�c��9�
+Uf�UX���s���r��58��8�+��O�%>s�/nO�PeV%P Y�q�����~��C�L���� |-
+/daggerdbl 233 -| ��f�D������8���Xm���L6�w�|y���i�w�����u]��F����d��5��NX*�{�0�t�9 KT,P��S�){���2�!�RwGB'�
+�KM>r��4I��Kv��rq��
+O�������������$An�����������%��+�����V�6�{AL��������+/periodcentered 25 -| �������cSm�������S |-
+/paragraph 101 -| ��u��������^[x�!? �an�e;K=S�h�8~3����!���}w��%�0a�2��g7��ES�E�|����N��)������R�*���>m��
+� |-
+/bullet 44 -| ��f��J������9tf�,���n��on��-FZ������� |-
+/quotesinglbase 24 -| ��
+q���,$3�-��x�M�"v� |-
+/quotedblbase 35 -| ��
+~�0������Y�������;S������ |-
+/quotedblright 34 -| ��
+~�0��������Q�?��/����]H~�� |-
+/guillemotright 43 -| ��j{tX�[F;X�b,�[�jh�5����=���X���A.���� |-
+/ellipsis 44 -| ��-�����"dj��g���W���E�a�U
+1Ze9�4:�<��qS |-
+/perthousand 108 -| ��c!}{&��*Y��"�;7A��<G����x��/���K],��J`�`
+3�rOE��,���Z�B�w0n���+�cc,Uf��S��Q�1�3������I��� |-
+/questiondown 147 -| ��w���L����n��$�}P.��U$6A�@���r[kuj,[��l�H�<�p��WD�]*c������gc\(����B��J�.���+���/Lcs8Yw��. |-
+/grave 25 -| ��b�}K��|�}u�n0��B��*� |-
+/acute 25 -| ��)8����� ��?9��
+V�� |-
+/circumflex 29 -| ��dU!�C��� ��}eqQ%3,��"� |-
+/tilde 37 -| ���/�p��,��n?%�5��y��@���?R |-
+/macron 28 -| �����G����
+"�X�x���w�R |-
+/breve 60 -| ���z�7��y�"�=��qL�^%H�W�v�&��5,�1�Z�����q����q�4SJ�:��� |-
+/dotaccent 24 -| ��):R���n�����E���%
+ |-
+/dieresis 27 -| ��q�/{BM�$�j���V��L�
+ |-
+/ring 31 -| ��9��6�qy+/cedilla 29 -| ��)-���Mh�cv��N�H��j�8]EA� |-
+/hungarumlaut 32 -| ��.���/���"jA���u�����K/��� |-
+/ogonek 66 -| ��,}[��<�T�3!w
+�����-��O���p���r��0��U�����.����X�ywQ�<�-�*�� |-
+/caron 28 -| ��dU!�C��� �J ����>f� � |-
+/emdash 28 -| ��Un^���s����$�+?��Ii��� |-
+/AE 148 -| ���>8vG�5�m[���z"���yg�/49��?/45A�i����� �L7�I�-%��� �����~n����n��h��_����s#W3��X�<"���[��4�b)��$����Ow�\,xX�����!D%�-��~�{� |-
+/ordfeminine 174 -| ��mo������J�o�P����+8_/2zf�Y�l|P�t��#�e��`c,��2�6
+�
+W��� J��L�;l���~�%���u�M�t���T����}�ox}~�R��kD?u�����E��M��:t�Rr�"������ 2s��K |-
+/Lslash 73 -| ��q���H��'��i����"/�)h��u��
+�#���Li��HK��+����"�
+��}��![A��
+Uy�3 |-
+/Oslash 132 -| ��e�g�%�t����~s���#�.o���(y^�A�Q��P���H3zcl��������e�G�J}d�S���&�K����������GF���T����'-.�R���m����{�,F�B���M�bW�~�
+4�f�� |-
+/OE 108 -| ��e���Jmo&�O��rJ���{�y�W�z�Ct���L��~0f�������n?\����7�J^)��C_�&�d������`F����m����� #��+���t�
+1��� |-
+/ordmasculine 87 -| ��p�{�n�l2������?���U���� �S�������6+/ae 156 -| ��b��xuK�!�.E}l)�]���������c�:0���0(�����",z~)�?���5��V4b�GLQ���������}Ku8�.p��������1`�9����r�
+-73���@�~6� <�hQ��(�j��M�P�vbW.1��O��I%�� |-
+/dotlessi 12 -| ��u�UzS�x |-
+/lslash 56 -| ��G��*�i��+/oslash 133 -| ��b��R[��+
+���`�9��A`�bt�8��(��zd����5+/oe 105 -| ��b��;�,��T��%��Bu�B/U|���3��h������,��
+Y��i(��x����*b"3�:��g�%:���g������������E$�S��� w |-
+/germandbls 181 -| ����N��e�xj��lZ+/onesuperior 39 -| ��_���0\E��G�? �� -Y�{x�[t}+K��h�� |-
+/minus 29 -| ��h�1��#/������vWe������ |-
+/degree 79 -| ��nJ�6����D����)w�,~�4�)����yQi#�P���|��U+/oacute 21 -| ��b��R'�+/Odieresis 24 -| ��e�g�%�t��ST�
+K���q�� |-
+/odieresis 25 -| ��b��R'�+�B�!3L��� |-
+/Eacute 24 -| ��p��z���g������+/ucircumflex 26 -| ��{� (���Z^h/�7��%�l�4 |-
+/onequarter 70 -| ��w
+g"��]?�q�Xn
+3}���
+A<������'?�����a�A�%"��Tz{'�K��XUu�Y�'*��j |-
+/logicalnot 35 -| ��h�1�^7f��Us2��P�:o'?���*X��@� |-
+/Ecircumflex 24 -| ��p��z���#V�+��ZX�'
+C |-
+/onehalf 54 -| ��)s!G,W��[��<�����9W������M��{�'�yL;5�Q3+/Otilde 40 -| ��e�g�%�t��ST�C4�|t6�{���`��(Md%�� |-
+/uacute 26 -| ��{� (���'��nb��_z\Mg�� |-
+/eacute 22 -| ��b��h+/iacute 18 -| ��u�UzS��v'|�0 |-
+/Egrave 24 -| ��p��z���g�����(j;�z� |-
+/icircumflex 67 -| ��V��[�N��GrF�'i�3�fB�!��������]<c��Sq4��g��S7Ed���>�� 0�z |-
+/mu 83 -| ��{� (�\��1�C)F#�,7�:�e�b5:^����hQ���E%-T(�yM=H��j9�!�:�)�\���51�ND��W� |-
+/brokenbar 40 -| �����ICo��de/�d��_��T���e����%����J� |-
+/thorn 107 -| ��|�f����{'�F8���I#����o������������r���#�{��p�V�&�8�,0������?�;=Z�)����S�{���$w"x/(]2������������ |-
+/Aring 98 -| ����je��\u^��R4�J�0*� \�_�LZ�]���r~�~���.Z�Ya|o�4� �~� e�5��?����>qt��^-A�[�x)��N��g� |-
+/yacute 17 -| ��X�������N�H� |-
+/Ydieresis 22 -| ���%������85A�Y�� |-
+/trademark 221 -| ��f�{����+���FSv��\�m����h'��@���G�+?@��_6���#��E�+�s��ddV*��t�C[�b��� ��E�������b��K��y
+w�e*�Y���#�X�����e�����R����2������0�k������F��y�o=�u�������7?d�(I�1���R�jBX�5��xt�����4�� |-
+/registered 162 -| ��f��E������������^�zCl�(�5�E�����LM]�XF(���RT����-0r��������j��d�,X8�K��6tCwR��L��m� Y��
+ ��O��q_���_gK���c���>6_��k����-i����e[W�4mH[ |-
+/ocircumflex 26 -| ��b��R'�+/Agrave 19 -| �����<
+z�a�2@�� |-
+/Scaron 26 -| ��c&4����P�f�8t����e� |-
+/Ugrave 21 -| ��v��*��a��u���F��m |-
+/Edieresis 25 -| ��p��z���#F�[V�:"��`��� |-
+/Uacute 21 -| ��v��*��a��u�h�
+�2 |-
+/otilde 40 -| ��b��R'7�\r
+%�����~��V9�� 2��Jz��u |-
+/ntilde 39 -| ��u������<8[i��)�?VO��z
+Q��k��?� |-
+/ydieresis 35 -| ��X����Z]{�k7���|�� ���
+[�2�' |-
+/Aacute 18 -| �����<
+��i��� |-
+/eth 146 -| ��b��R'H}�\���fy�
+O+A�����awP6�.Wo�e���/�LI��V�i�4�R��xc���H;q1{��d������>�Z��������DuQTWj�O�L^zW�R�H�B��[�,(�a3OA�1gD�C�g�e<�U�q�Ac�# |-
+/acircumflex 25 -| ��b��.2{s����<-O�8�V�� |-
+/aring 59 -| ��b��.1������x�b"�
+�6�tc�c�w=���}��a�^~� ���h1c�Y��n� |-
+/Ograve 20 -| ��e�g�%�t��Sv�S��= |-
+/ccedilla 110 -| ��b����[*��h]<yq����S��������q���TT2�`�DYG@�k�'��47���'�9k���EZ�m����y��g,���TVg+/multiply 70 -| ����b�e5AJ���s�[��!%n���8�������`u��La qf:W��C}%O��{��7<) �1m��m� |-
+/divide 54 -| ��h�1�rD'���"'=��_��sbr/L�~�tM��,���j��������H��� |-
+/twosuperior 28 -| ��u����B+/Ntilde 36 -| ��s<I����N�����M�Yq5������]�p��C |-
+/ugrave 25 -| ��{� (���'��nb�*��A�t |-
+/Ucircumflex 25 -| ��v��*��a���$^\������W |-
+/Atilde 47 -| �����<���cd+|D�c�)����������v�8�^v~�I� |-
+/zcaron 47 -| ��@]�[$�4�;-�/�`�
+Nq�{�k�yr�yy!�6\�QS��� |-
+/idieresis 68 -| ���y��,�i��vP����@��%����9l������7{��������i$�j�o����$K�� |-
+/Acircumflex 36 -| �����@<��}{���s��'��<�)`T����� |-
+/Icircumflex 34 -| �����F��r~,������N_��$�/h |-
+/Yacute 19 -| ���%��������W�� |-
+/Oacute 20 -| ��e�g�%�t��S��O"U� |-
+/Adieresis 51 -| �����@�}&�'Dof�V�h�i��B��;���+� |-
+/Zcaron 27 -| ��JND�x��dp4�I�C���_����� |-
+/agrave 21 -| ��b��.2{s�.����/z � |-
+/threesuperior 68 -| ��q�X��$���F��Jw*Vnm�M������t��H,n��J6��x��)��C2������?+� |-
+/ograve 22 -| ��b��R'�+�s�w0(� |-
+/threequarters 114 -| ��c'��UKd]�l��"������ ������y!(m8T��'2���Br�R|�`+Y[������E?�����%Z���r#9�x"��l�k9�D`�}d��bbT1��K� |-
+/Eth 70 -| �=t*��S�[�+�&�����N���wz�0_�D'���0 �7V�U����O�$���]�F 7#!'�i� |-
+/plusminus 66 -| �=t*>]0���h"���R�8D�>�����.~���M�zcF��" \����Q����j�u�
+A�@��1H |-
+/udieresis 55 -| �=t*-�4���8jP��b��d��]�����uNh?��I�[6�g�������&�m� |-
+/edieresis 26 -| �=t*4mK����T9$p��a�����aW |-
+/aacute 22 -| �=t*4mBh9*��4lfJ0
+�Z |-
+/igrave 38 -| �=t*����D�_�q:�E�_�����K9�&�T��� |-
+/Idieresis 36 -| �=t*y"F����}� O�i�2i�[a�a_��� |-
+/adieresis 29 -| �=t*4mBh9*��P����W�I�1����� |-
+/Iacute 27 -| �=t*&��f+/copyright 111 -| �=t*0���g�����;Qw���].u��m����Ud��a��>2�Av�Ko��Ux�l��(��������P�\i���u/�5��@��Izy������qO.?�++/Igrave 30 -| �=t*a�w��;
+y}���K���V�R�<�� |-
+/Ccedilla 57 -| �=t*3?�q���s���~u����e�PQMb�V����(xC��O����3wPH{ |-
+/scaron 43 -| �=t*2+/egrave 20 -| �=t*4mK����T9$��v� |-
+/Ocircumflex 25 -| �=t*3?�3����%|D��$g��]�� |-
+/Thorn 111 -| �=t*&�81���������e��s�,n���@�]��8����-����� ��Z���f�� ,�.r���e+e} 5���W��^������Z��Fnb��rq�.|�
+p� |-
+/atilde 39 -| �=t*4mBh9��O��&������8@RT���NeQ��#�� |-
+/Udieresis 25 -| �=t* �12[��@�4�����0��c |-
+/ecircumflex 25 -| �=t*4mK����Z+�~�����r�:�� |-
+/.notdef 9 -| �=t*�g�� |-
+end
+end
+readonly put
+noaccess put
+dup/FontName get exch definefont pop
+mark currentfile closefile
Property changes on: trunk/foray/foray-ps-data/src/test/ps/putr_eexec.ps
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-05 23:53:29
|
Revision: 13821
http://sourceforge.net/p/foray/code/13821
Author: victormote
Date: 2025-06-05 23:53:25 +0000 (Thu, 05 Jun 2025)
Log Message:
-----------
Discard the 4 random starting bytes right in the filter.
Modified Paths:
--------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-06-05 18:15:59 UTC (rev 13820)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-06-05 23:53:25 UTC (rev 13821)
@@ -90,6 +90,19 @@
@Override
public int read() throws IOException {
+ /* Ignore the initial random bytes. */
+ while (this.bytesRead < EEXEC_RANDOM_BYTES) {
+ internalRead();
+ }
+ return internalRead();
+ }
+
+ /**
+ * Internal read of one byte.
+ * @return One decrypted byte.
+ * @throws IOException For IO errors reading the underlying stream.
+ */
+ private int internalRead() throws IOException {
final int cipherText = in.read();
if (cipherText < 0) {
return -1;
@@ -104,12 +117,6 @@
temp2 += EexecDecodeFilter.ENCRYPTION_CONSTANT_2;
temp2 %= PrimitiveConstants.MAX_16_BIT_UNSIGNED_VALUES;
this.encryptionKey = (int) temp2;
-
- /* The initial random bytes are meaningless and should be discarded by the downstream user.
- * We convert them to ASCII spaces for readability. */
- if (this.bytesRead <= EEXEC_RANDOM_BYTES) {
- return ' ';
- }
return plainText;
}
Modified: trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java
===================================================================
--- trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java 2025-06-05 18:15:59 UTC (rev 13820)
+++ trunk/foray/foray-ps-data/src/test/java/org/foray/ps/filter/EexecDecodeFilterTests.java 2025-06-05 23:53:25 UTC (rev 13821)
@@ -60,9 +60,15 @@
fis.close();
/* Take only the portion of the file that is encrypted. These values were obtained by looking at the file. */
- final int qtyBytes = 70956;
+ final int totalBytes = 72_354;
+ final int qtyPart1Bytes = 866;
+ final int qtyPart3Bytes = 532;
+ final int qtyLineFeeds = 1_092;
+
+ final int qtyBytes = totalBytes - qtyPart1Bytes - qtyPart3Bytes;
+ assertEquals(70_956, qtyBytes);
final byte[] encodedBytes = new byte[qtyBytes];
- System.arraycopy(bytes, 866, encodedBytes, 0, encodedBytes.length);
+ System.arraycopy(bytes, qtyPart1Bytes, encodedBytes, 0, encodedBytes.length);
assertEquals(qtyBytes, encodedBytes.length);
/* Create input stream containing the raw input bytes. */
@@ -79,7 +85,8 @@
/* See {@link AsciiHexDecodeFilter#testWithFontInput()} for size computation. */
final ByteArrayBuilder builder = new ByteArrayBuilder(34932);
builder.append(filter);
- assertEquals(34932, builder.length());
+ final int expectedLength = ((qtyBytes - qtyLineFeeds) / 2) - EexecDecodeFilter.EEXEC_RANDOM_BYTES;
+ assertEquals(expectedLength, builder.length());
final byte[] plaintextBytes = builder.toArray();
/* Convert the byte array to list of String, one per line. */
@@ -89,7 +96,7 @@
/* Test the output. Some of the lines contain non-ASCII data, which got destroyed above, so we just look at the
* ASCII portion of the line in those cases. */
assertEquals(777, lines.size());
- assertEquals(" dup /Private 17 dict dup begin", lines.get(0));
+ assertEquals("dup /Private 17 dict dup begin", lines.get(0));
assertNotNull(lines.get(760));
assertEquals("/Ccedilla 57 -| ", lines.get(760).substring(0, 16));
assertEquals("mark currentfile closefile", lines.get(776));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-05 18:16:01
|
Revision: 13820
http://sourceforge.net/p/foray/code/13820
Author: victormote
Date: 2025-06-05 18:15:59 +0000 (Thu, 05 Jun 2025)
Log Message:
-----------
Improvements to stream handling in eexec.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-05 18:04:30 UTC (rev 13819)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-05 18:15:59 UTC (rev 13820)
@@ -30,6 +30,7 @@
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.ByteArrayBuilder;
+import org.foray.ps.filter.AsciiHexDecodeFilter;
import org.foray.ps.filter.EexecDecodeFilter;
import org.axsl.constants.PrimitiveConstants;
@@ -40,6 +41,7 @@
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.io.IOException;
+import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -1834,14 +1836,29 @@
/* Create the operand for eexec. */
final PsObject toExec = popOperand(PsOperator.EEXEC);
- PsInputStream stream = null;
+ PsInputStream rawStream = null;
if (toExec instanceof PsInputStream) {
- stream = (PsInputStream) toExec;
+ rawStream = (PsInputStream) toExec;
} else {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.EEXEC);
}
- final EexecDecodeFilter filter = new EexecDecodeFilter(stream);
+ InputStream binaryStream = null;
+ boolean isAsciiHex = false;
+ try {
+ isAsciiHex = EexecDecodeFilter.isAsciiHex(rawStream);
+ } catch (final IOException e) {
+ /* Ignore for now. */
+ }
+ if (isAsciiHex) {
+ final AsciiHexDecodeFilter hexFilter = new AsciiHexDecodeFilter(rawStream);
+ binaryStream = hexFilter;
+ } else {
+ binaryStream = rawStream;
+ }
+
+
+ final EexecDecodeFilter filter = new EexecDecodeFilter(binaryStream);
final PsGenericInputStream gis = new PsGenericInputStream(filter);
/* From "PostScript Language Reference, 3rd Edition" 8.2 eexec: "causes the contents of file (open for reading)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-05 18:04:33
|
Revision: 13819
http://sourceforge.net/p/foray/code/13819
Author: victormote
Date: 2025-06-05 18:04:30 +0000 (Thu, 05 Jun 2025)
Log Message:
-----------
Add support for mark and related input stream methods.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-05 11:29:14 UTC (rev 13818)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-05 18:04:30 UTC (rev 13819)
@@ -128,4 +128,19 @@
return this.fis.read();
}
+ @Override
+ public synchronized void mark(final int readlimit) {
+ this.fis.mark(readlimit);
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ this.fis.reset();
+ }
+
+ @Override
+ public boolean markSupported() {
+ return this.fis.markSupported();
+ }
+
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-05 11:29:14 UTC (rev 13818)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-05 18:04:30 UTC (rev 13819)
@@ -78,4 +78,19 @@
return this.inputStream.read();
}
+ @Override
+ public synchronized void mark(final int readlimit) {
+ this.inputStream.mark(readlimit);
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ this.inputStream.reset();
+ }
+
+ @Override
+ public boolean markSupported() {
+ return this.inputStream.markSupported();
+ }
+
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-05 11:29:14 UTC (rev 13818)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-05 18:04:30 UTC (rev 13819)
@@ -54,6 +54,9 @@
/** Index to the next char in the stream. */
private int nextIndex = 0;
+ /** The current input stream mark. */
+ private int mark = -1;
+
/**
* Constructor for a byte array.
* @param value The value to encapsulate.
@@ -192,4 +195,21 @@
return this.value.byteAt(nextIndex - 1);
}
+ @Override
+ public synchronized void mark(final int readlimit) {
+ this.mark = this.nextIndex;
+ /* The readlimit is not relevant to a String that is 100% in memory always. */
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ this.nextIndex = this.mark;
+ this.mark = -1;
+ }
+
+ @Override
+ public boolean markSupported() {
+ return true;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-05 11:29:33
|
Revision: 13818
http://sourceforge.net/p/foray/code/13818
Author: victormote
Date: 2025-06-05 11:29:14 +0000 (Thu, 05 Jun 2025)
Log Message:
-----------
Improvements to eexec operator and related functionality.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsExecutionStack.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java 2025-06-04 20:22:40 UTC (rev 13817)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java 2025-06-05 11:29:14 UTC (rev 13818)
@@ -39,6 +39,7 @@
* An Adobe Type 1 font.
*/
public class Type1Font extends FontContent {
+ /* TODO: Tracking the segments should now be superfluous if the PostScript eexec is operating properly. */
/** The number of segments in each Type 1 font file. */
protected static final int QTY_SEGMENTS = 3;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java 2025-06-04 20:22:40 UTC (rev 13817)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java 2025-06-05 11:29:14 UTC (rev 13818)
@@ -31,7 +31,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
import org.foray.font.format.FontParserClient;
-import org.foray.primitive.sequence.ByteArrayBuilder;
import org.axsl.font.FontException;
import org.axsl.ps.PsException;
@@ -145,6 +144,8 @@
* @throws IOException For errors reading content.
*/
private void parseBasics() throws FontException {
+ /* TODO: It is doubtful that we still need to track these segments if the PostScript parser is handling eexec
+ * properly. */
try {
this.segments = computeSegmentBoundaries();
for (int index = 0; index < this.segments.length; index ++) {
@@ -163,49 +164,13 @@
*/
protected abstract Segment[] computeSegmentBoundaries() throws IOException;
-
/**
- * Creates a PsInput intended to replicate the anonymous PsInput implementation in parseFontDictionary.
- * @return A PsInput instance.
- */
- protected InputStream getAltInput2() {
- final int size = this.segments[0].size + this.segments[1].size + this.segments[2].size;
- final ByteArrayBuilder builder = new ByteArrayBuilder(size);
- builder.append(this.segments[0].content);
- builder.append(this.segments[1].content);
- builder.append(this.segments[2].content);
- final byte[] bytes = builder.toArray();
- return new ByteArrayInputStream(bytes);
- }
-
- /**
- * Runs the whole file through the interpreter.
- * @return The input containing the entire font file.
- */
- protected InputStream getAltInput3() {
- return new ByteArrayInputStream(this.parser.getRandomInput().getByteSequence().toArray());
- }
-
- /**
- * Just run segment 1 through the interpreter.
- * @return The input containing the entire font file.
- */
- protected InputStream getAltInput4() {
- return new ByteArrayInputStream(this.segments[0].content);
- }
-
- /**
* Parses the detail information from the file.
* @return The parsed font dictionary.
*/
private PsFontDictionary parseFontDictionary() {
- final int alt = 4;
- InputStream input = null;
- switch (alt) {
- case 2: input = getAltInput2(); break;
- case (2 + 1): input = getAltInput3(); break;
- case (2 + 2): input = getAltInput4(); break;
- }
+ /* TODO: Find a cleaner way to get this input stream. */
+ final InputStream input = new ByteArrayInputStream(this.parser.getRandomInput().getByteSequence().toArray());
final PsServer psServer = getParserClient().getPsServer();
PsInterpreter interpreter = null;
final PsSystemDict systemDict = psServer.getReadOnlySystemDict();
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsExecutionStack.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsExecutionStack.java 2025-06-04 20:22:40 UTC (rev 13817)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsExecutionStack.java 2025-06-05 11:29:14 UTC (rev 13818)
@@ -28,8 +28,6 @@
package org.foray.ps;
-import java.util.List;
-
/**
* A PostScript Execution stack.
*/
@@ -54,23 +52,6 @@
return PsError.UNDEFINED;
}
- /**
- * Returns the top PsFile object in the stack.
- * @return The top PsFile object in the stack, or null if there
- * is none.
- */
- PsFile currentFile() {
- PsFile currentFile = null;
- final List<PsObject> list = this.getList();
- for (int i = list.size() - 1; i > -1 && currentFile == null;
- i--) {
- if (list.get(i) instanceof PsFile) {
- currentFile = (PsFile) list.get(i);
- }
- }
- return currentFile;
- }
-
@Override
protected PsObject filterPush(final PsObject objectToPush) {
if (objectToPush instanceof PsArray
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-04 20:22:40 UTC (rev 13817)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-05 11:29:14 UTC (rev 13818)
@@ -29,6 +29,7 @@
package org.foray.ps;
import org.foray.primitive.sequence.ByteArray;
+import org.foray.primitive.sequence.ByteArrayBuilder;
import java.io.IOException;
@@ -54,14 +55,23 @@
private int nextIndex = 0;
/**
- * Constructor.
+ * Constructor for a byte array.
* @param value The value to encapsulate.
*/
public PsString(final ByteArray value) {
- super();
this.value = value;
}
+ /**
+ * Constructor for a String or other CharSequence. Converts the chars to bytes using the "US-ASCII" charset.
+ * @param value The value to encapsulate.
+ */
+ public PsString(final CharSequence value) {
+ final ByteArrayBuilder builder = new ByteArrayBuilder();
+ builder.append(value);
+ this.value = builder.toImmutable();
+ }
+
@Override
public PsObject duplicate() {
return this;
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-04 20:22:40 UTC (rev 13817)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-05 11:29:14 UTC (rev 13818)
@@ -30,6 +30,7 @@
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.ByteArrayBuilder;
+import org.foray.ps.filter.EexecDecodeFilter;
import org.axsl.constants.PrimitiveConstants;
@@ -1789,9 +1790,20 @@
* @throws PsOperatorException For any PostScript error.
*/
private void currentfile() {
- final PsFile currentFile = getInterpreter().getExecutionStack()
- .currentFile();
- pushOperand(currentFile);
+ /* The "currentfile" doc says this operator returns "the topmost file object on the execution stack."
+ * TODO: This method is therefore possibly wrong in two ways.
+ * 1. We understand "file" to mean "stream" which could include a PsString.
+ * 2. We are not sure what to do if the topmost item is not a "file" or other stream. Should the stack be
+ * traversed until one is found? Should non-file items on the stack be popped and then pushed to the operand
+ * stack? */
+ final PsObject psObject = getInterpreter().getExecutionStack().peek();
+ if (psObject instanceof PsInputStream) {
+ final PsInputStream psInputStream = (PsInputStream) psObject;
+ pushOperand(psInputStream);
+ } else {
+ /* Per "currentfile" doc, this never occurs during execution of ordinary user programs. */
+ pushOperand(new PsString(""));
+ }
}
/**
@@ -1813,29 +1825,36 @@
private void eexec() throws PsOperatorException, PsInterpreterException4a {
final PsOperandStack operandStack = getInterpreter().getOperandStack();
- /* From "PSLR 3rd Edition" 8.2 eexec: "Before beginning execution, eexec pushes systemdict on the dictionary
- * stack ..."
+ /* From "PostScript Language Reference, 3rd Edition" 8.2 eexec: "Before beginning execution, eexec pushes
+ * systemdict on the dictionary stack ..."
* From "Adobe Type 1 Font Format" 2.3: "When eexec begins operation, it performs a begin operation on
* systemdict ..." */
operandStack.push(getInterpreter().getSystemDict());
begin();
- /* TODO: Badly broken at the moment during refactoring. */
+ /* Create the operand for eexec. */
+ final PsObject toExec = popOperand(PsOperator.EEXEC);
+ PsInputStream stream = null;
+ if (toExec instanceof PsInputStream) {
+ stream = (PsInputStream) toExec;
+ } else {
+ throw new PsOperatorException(PsError.TYPECHECK, PsOperator.EEXEC);
+ }
- /* Create the operand for eexec. */
-// final PsObject toExec = popOperand(PsOperator.EEXEC);
-// final EexecDecodeFilter filter = new EexecDecodeFilter(null);
- final PsFile file = null;
-// if (toExec instanceof PsFile) {
-// file = new PsFileFilter(filter, (PsFile) toExec);
-// } else {
-// throw new PsOperatorException(PsError.TYPECHECK, PsOperator.EEXEC);
-// }
- operandStack.push(file);
+ final EexecDecodeFilter filter = new EexecDecodeFilter(stream);
+ final PsGenericInputStream gis = new PsGenericInputStream(filter);
+
+ /* From "PostScript Language Reference, 3rd Edition" 8.2 eexec: "causes the contents of file (open for reading)
+ * or string to be decrypted and then executed in a manner similar to the exec operator.... It pushes the new
+ * file objecton the execution stack." Instead of pushing it directly onto the execution stack, we instead put
+ * it on the operand stack, and then call "exec" which pops it from the operand stack and pushes it to the
+ * execution stack before doing its work. This allows eexec to know when exec has finished, and do its cleanup
+ * work (below). */
+ operandStack.push(gis);
exec();
- /* From "PSLR 3rd Edition" 8.2 eexec: "When the decryption filter file is closed either explicitly or
- * implicitly, the dictionary stack is popped."
+ /* From "PostScript Language Reference, 3rd Edition" 8.2 eexec: "When the decryption filter file is closed
+ * either explicitly or implicitly, the dictionary stack is popped."
* From "Adobe Type 1 Font Format" 2.3: "When eexec terminates, it automatically performs an end operation to
* remove the systemdict that it begins here." */
end();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-04 20:22:43
|
Revision: 13817
http://sourceforge.net/p/foray/code/13817
Author: victormote
Date: 2025-06-04 20:22:40 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Fix data type in test, affected by recent change to underlying array in PsName.
Modified Paths:
--------------
trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
Modified: trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
===================================================================
--- trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-04 19:59:10 UTC (rev 13816)
+++ trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-04 20:22:40 UTC (rev 13817)
@@ -753,7 +753,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsName);
final PsName psName = (PsName) object;
- assertEquals("add", psName.getValue());
+ assertEquals(new ByteArray("add"), psName.getValue());
/* Test second operand on stack. */
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-04 19:59:13
|
Revision: 13816
http://sourceforge.net/p/foray/code/13816
Author: victormote
Date: 2025-06-04 19:59:10 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Pop the execution stack before consuming the last token.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-04 19:04:05 UTC (rev 13815)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-04 19:59:10 UTC (rev 13816)
@@ -394,9 +394,9 @@
} catch (final IOException e) {
/* Nothing useful to do here. */
}
+ this.executionStack.pop();
/* Consume any in-process token. */
consumeToken();
- this.executionStack.pop();
return;
}
final byte byteToConsume = (byte) intToConsume;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-04 19:04:08
|
Revision: 13815
http://sourceforge.net/p/foray/code/13815
Author: victormote
Date: 2025-06-04 19:04:05 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Add tests of equals() and hasCode().
Modified Paths:
--------------
trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractByteSequenceTests.java
Modified: trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractByteSequenceTests.java
===================================================================
--- trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractByteSequenceTests.java 2025-06-04 12:12:14 UTC (rev 13814)
+++ trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractByteSequenceTests.java 2025-06-04 19:04:05 UTC (rev 13815)
@@ -28,9 +28,14 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractByteSequence;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.junit.jupiter.api.Test;
+import java.util.Arrays;
+
/**
* JUnit tests of {@link AbstractByteSequence4a}.
*/
@@ -41,13 +46,64 @@
/* 0 1 2 */
/* 012345678901234567890123456789 */
- /** A test sequence.
- * 012345678901234567890123456789012345678*/
+ /** A test sequence. */
private ByteArray test2 = new ByteArray("belly, jelly, smelly, bell, jell, smell.");
- /* 0 1 2 3 */
- /* 012345678901234567890123456789012345678 */
+ /* 0 1 2 3 */
+ /* 0123456789012345678901234567890123456789 */
+
+
+
/**
+ * Tests of {@link AbstractByteSequence#equals}, where a "true" response is expected.
+ */
+ @Test
+ public void testEqualsPositive() {
+ final ByteArrayBuilder builder = new ByteArrayBuilder();
+ builder.append(test1);
+ final ByteArray test1Dup = builder.toImmutable();
+ assertEquals(test1, test1Dup);
+
+ builder.setLength(0);
+ builder.append(test2);
+ final ByteArray test2Dup = builder.toImmutable();
+ assertEquals(test2, test2Dup);
+ }
+
+ /**
+ * Tests of {@link AbstractByteSequence#equals}, where a "false" response is expected.
+ */
+ @Test
+ public void testEqualsNegative() {
+ final ByteArrayBuilder builder = new ByteArrayBuilder();
+ builder.append(test1);
+ builder.append('a');
+ final ByteArray test1Dup = builder.toImmutable();
+ assertNotEquals(test1, test1Dup);
+
+ builder.setLength(0);
+ builder.append(test1);
+ builder.setByteAt(21, (byte) '!');
+ final ByteArray test2Dup = builder.toImmutable();
+ assertNotEquals(test2, test2Dup);
+ }
+
+ /**
+ * Tests of {@link AbstractByteSequence#hashCode}.
+ * Testing that
+ */
+ @Test
+ public void testHashCode() {
+ final int expectedHashCode1 = Arrays.hashCode(test1.toArray());
+ final int actualHashCode1 = test1.hashCode();
+ assertEquals(expectedHashCode1, actualHashCode1);
+
+ final int expectedHashCode2 = Arrays.hashCode(test2.toArray());
+ final int actualHashCode2 = test2.hashCode();
+ assertEquals(expectedHashCode2, actualHashCode2);
+ }
+
+ /**
* Tests of method {@link AbstractByteSequence4a#indexOf(int)}.
*/
@Test
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-04 12:12:20
|
Revision: 13814
http://sourceforge.net/p/foray/code/13814
Author: victormote
Date: 2025-06-04 12:12:14 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Conform to aXSL change: 1. Add type-specific abstract classes to house the equals and hashCode methods. 2. Move existing code in ByteSequence to new abstract class.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence4a.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -30,7 +30,7 @@
import org.foray.primitive.ByteUtils;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractByteSequence;
import org.axsl.primitive.sequence.BytePrimitiveIterator;
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -46,7 +46,7 @@
*
* Note that many of the methods in this class were adapted from {@link java.lang.String}.
*/
-public abstract class AbstractByteSequence4a extends AbstractPrimitiveSequence implements ByteSequencePlus {
+public abstract class AbstractByteSequence4a extends AbstractByteSequence implements ByteSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -7127309629480150165L;
@@ -80,16 +80,6 @@
}
@Override
- public boolean equals(final Object other) {
- return altEquals(other);
- }
-
- @Override
- public int hashCode() {
- return altHashCode();
- }
-
- @Override
public String difference(final Object other) {
if (other == null) {
return "Comparison object is null.";
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractCharSequence;
import org.axsl.primitive.sequence.CharPrimitiveIterator;
import org.axsl.primitive.sequence.CharSequenceMutable;
import org.axsl.primitive.sequence.CharSequencePlus;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link CharSequencePlus}.
*/
-public abstract class AbstractCharSequence4a extends AbstractPrimitiveSequence implements CharSequencePlus {
+public abstract class AbstractCharSequence4a extends AbstractCharSequence implements CharSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -4790770925304512788L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractDoubleSequence;
import org.axsl.primitive.sequence.DoublePrimitiveIterator;
import org.axsl.primitive.sequence.DoubleSequence;
import org.axsl.primitive.sequence.DoubleSequenceMutable;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link DoubleSequencePlus}.
*/
-public abstract class AbstractDoubleSequence4a extends AbstractPrimitiveSequence implements DoubleSequencePlus {
+public abstract class AbstractDoubleSequence4a extends AbstractDoubleSequence implements DoubleSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -460518736372819472L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractFloatSequence;
import org.axsl.primitive.sequence.FloatPrimitiveIterator;
import org.axsl.primitive.sequence.FloatSequence;
import org.axsl.primitive.sequence.FloatSequenceMutable;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link FloatSequencePlus}.
*/
-public abstract class AbstractFloatSequence4a extends AbstractPrimitiveSequence implements FloatSequencePlus {
+public abstract class AbstractFloatSequence4a extends AbstractFloatSequence implements FloatSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = 5696774869086963028L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractIntSequence;
import org.axsl.primitive.sequence.IntPrimitiveIterator;
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link IntSequencePlus}.
*/
-public abstract class AbstractIntSequence4a extends AbstractPrimitiveSequence implements IntSequencePlus {
+public abstract class AbstractIntSequence4a extends AbstractIntSequence implements IntSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -7886656099618775680L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractLongSequence;
import org.axsl.primitive.sequence.LongPrimitiveIterator;
import org.axsl.primitive.sequence.LongSequence;
import org.axsl.primitive.sequence.LongSequenceMutable;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link LongSequencePlus}.
*/
-public abstract class AbstractLongSequence4a extends AbstractPrimitiveSequence implements LongSequencePlus {
+public abstract class AbstractLongSequence4a extends AbstractLongSequence implements LongSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -6030416496206309157L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence4a.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence4a.java 2025-06-04 12:12:14 UTC (rev 13814)
@@ -28,7 +28,7 @@
package org.foray.primitive.sequence;
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.AbstractShortSequence;
import org.axsl.primitive.sequence.ShortPrimitiveIterator;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.primitive.sequence.ShortSequenceMutable;
@@ -37,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link ShortSequencePlus}.
*/
-public abstract class AbstractShortSequence4a extends AbstractPrimitiveSequence implements ShortSequencePlus {
+public abstract class AbstractShortSequence4a extends AbstractShortSequence implements ShortSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -9026237362654665973L;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-04 11:24:00
|
Revision: 13813
http://sourceforge.net/p/foray/code/13813
Author: victormote
Date: 2025-06-04 11:23:54 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Rename abstract classes in preparation for aXSL refactoring.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteSequenceChars.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteSequenceSubset.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/CharArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/CharArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/DoubleArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/DoubleArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/FloatArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/FloatArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/IntArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/IntArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/LongArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/LongArrayBuilder.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ShortArray.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ShortArrayBuilder.java
trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractByteSequenceTests.java
trunk/foray/foray-primitive/src/test/java/org/foray/primitive/sequence/AbstractIntSequenceTests.java
Added Paths:
-----------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence4a.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence4a.java
Removed Paths:
-------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence.java
Deleted: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-04 11:23:54 UTC (rev 13813)
@@ -1,775 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.primitive.sequence;
-
-import org.foray.primitive.ByteUtils;
-
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
-import org.axsl.primitive.sequence.BytePrimitiveIterator;
-import org.axsl.primitive.sequence.ByteSequence;
-import org.axsl.primitive.sequence.ByteSequencePlus;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.math.BigDecimal;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-/**
- * Abstract superclass for byte sequence classes.
- *
- * Note that many of the methods in this class were adapted from {@link java.lang.String}.
- */
-public abstract class AbstractByteSequence extends AbstractPrimitiveSequence implements ByteSequencePlus {
-
- /** Constant needed for serialization. */
- private static final long serialVersionUID = -7127309629480150165L;
-
- /** Byte array containing all whitespace characters. */
- private static final ByteArray WHITESPACE_CHARS = new ByteArray(" \n\r\t");
-
- @Override
- public String toString() {
- return toAscii();
- }
-
- @Override
- public String toString(final java.nio.charset.Charset charset) {
- return new String(toArray(), charset);
- }
-
- @Override
- public String toAscii() {
- return toString(StandardCharsets.US_ASCII);
- }
-
- @Override
- public CharSequence charSubSequence(final int start, final int end) {
- return subSequence(start, end).toAscii();
- }
-
- @Override
- public CharSequence charSubSequence(final int start, final int end, final Charset charset) {
- return subSequence(start, end).toString(charset);
- }
-
- @Override
- public boolean equals(final Object other) {
- return altEquals(other);
- }
-
- @Override
- public int hashCode() {
- return altHashCode();
- }
-
- @Override
- public String difference(final Object other) {
- if (other == null) {
- return "Comparison object is null.";
- }
- if (! (other instanceof ByteSequence)) {
- return "Comparison object is not a byte sequence.";
- }
- final ByteSequence otherSequence = (ByteSequence) other;
-
- final StringBuilder builder = new StringBuilder();
- if (length() != otherSequence.length()) {
- builder.append(String.format("Lengths are different: this %d, other %d.", this.length(),
- otherSequence.length()));
- }
-
- final int maxIndex = Math.min(this.length(), otherSequence.length());
- int diffIndex = -1;
- for (int index = 0; index < maxIndex; index ++) {
- if (byteAt(index) != otherSequence.byteAt(index)) {
- diffIndex = index;
- break;
- }
- }
- if (diffIndex < 0
- && length() != otherSequence.length()) {
- diffIndex = maxIndex + 1;
- }
-
- if (diffIndex > -1) {
- if (builder.length() > 0) {
- builder.append(" ");
- }
- builder.append(String.format("First difference is at index %d.", diffIndex));
- }
-
- return builder.toString();
- }
-
- @Override
- public int compareToLtR(final ByteSequence other) {
- final int len1 = length();
- final int len2 = other.length();
- final int lim = Math.min(len1, len2);
-
- int k = 0;
- while (k < lim) {
- final byte byte1 = byteAt(k);
- final byte byte2 = other.byteAt(k);
- if (byte1 != byte2) {
- return byte1 - byte2;
- }
- k++;
- }
- return len1 - len2;
- }
-
- @Override
- public int indexOf(final int aByte) {
- return indexOf(aByte, 0);
- }
-
- @Override
- public int indexOf(final int aByte, final int fromIndex) {
- if (aByte < Byte.MIN_VALUE
- || aByte > Byte.MAX_VALUE) {
- return -1;
- }
- final int max = length();
- int startIndex = fromIndex;
- if (fromIndex < 0) {
- startIndex = 0;
- } else if (fromIndex >= max) {
- return -1;
- }
- for (int i = startIndex; i < max; i++) {
- if (byteAt(i) == aByte) {
- return i;
- }
- }
- return -1;
- }
-
- @Override
- public int indexOf(final CharSequence str) {
- return indexOf(str, 0);
- }
-
- @Override
- public int indexOf(final CharSequence str, final int fromIndex) {
- return indexOf(0, length(), str, 0, str.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param fromIndex the index to begin searching from.
- * @return The index where {@code target} was found, or -1 if not found.
- * @see java.lang.String#indexOf(char[], int, int, String, int)
- */
- int indexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int fromIndex) {
- return indexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param targetOffset offset of the target sequence.
- * @param targetCount count of the target sequence.
- * @param fromIndex the index to begin searching from.
- * @return The index where {@code target} was found, or -1 if not found.
- * @see java.lang.String#indexOf(char[], int, int, char[], int, int, int)
- */
- int indexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int targetOffset,
- final int targetCount, final int fromIndex) {
- if (fromIndex >= sourceCount) {
- return targetCount == 0 ? sourceCount : -1;
- }
- int startIndex = fromIndex;
- if (fromIndex < 0) {
- startIndex = 0;
- }
- if (targetCount == 0) {
- return startIndex;
- }
-
- final char first = target.charAt(targetOffset);
- final int max = sourceOffset + (sourceCount - targetCount);
-
- for (int i = sourceOffset + startIndex; i <= max; i++) {
- /* Look for first character. */
- if (byteAt(i) != first) {
- while (++i <= max && byteAt(i) != first) { }
- }
-
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- int j = i + 1;
- final int end = j + targetCount - 1;
- for (int k = targetOffset + 1; j < end && byteAt(j) == target.charAt(k); j++, k++) { }
-
- if (j == end) {
- /* Found whole sequence. */
- return i - sourceOffset;
- }
- }
- }
- return -1;
- }
-
- @Override
- public int indexOf(final ByteSequence str) {
- return indexOf(str, 0);
- }
-
- @Override
- public int indexOf(final ByteSequence str, final int fromIndex) {
- return indexOf(0, length(), str, 0, str.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param fromIndex the index to begin searching from.
- * @return The index where {@code target} was found, or -1 if not found.
- * @see java.lang.String#indexOf(char[], int, int, String, int)
- */
- int indexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int fromIndex) {
- return indexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param targetOffset offset of the target sequence.
- * @param targetCount count of the target sequence.
- * @param fromIndex the index to begin searching from.
- * @return The index where {@code target} was found, or -1 if not found.
- * @see java.lang.String#indexOf(char[], int, int, char[], int, int, int)
- */
- int indexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int targetOffset,
- final int targetCount, final int fromIndex) {
- if (fromIndex >= sourceCount) {
- return targetCount == 0 ? sourceCount : -1;
- }
- int startIndex = fromIndex;
- if (fromIndex < 0) {
- startIndex = 0;
- }
- if (targetCount == 0) {
- return startIndex;
- }
-
- final byte first = target.byteAt(targetOffset);
- final int max = sourceOffset + (sourceCount - targetCount);
-
- for (int i = sourceOffset + startIndex; i <= max; i++) {
- /* Look for first character. */
- if (byteAt(i) != first) {
- while (++i <= max && byteAt(i) != first) { }
- }
-
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- int j = i + 1;
- final int end = j + targetCount - 1;
- for (int k = targetOffset + 1; j < end && byteAt(j) == target.byteAt(k); j++, k++) { }
-
- if (j == end) {
- /* Found whole sequence. */
- return i - sourceOffset;
- }
- }
- }
- return -1;
- }
-
- @Override
- public boolean contains(final byte testByte) {
- return indexOf(testByte) > -1;
- }
-
- @Override
- public int lastIndexOf(final int aByte) {
- return lastIndexOf(aByte, length() - 1);
- }
-
- @Override
- public int lastIndexOf(final int aByte, final int fromIndex) {
- int i = Math.min(fromIndex, length() - 1);
- for (; i >= 0; i--) {
- if (byteAt(i) == aByte) {
- return i;
- }
- }
- return -1;
- }
-
- @Override
- public int lastIndexOf(final CharSequence str) {
- return lastIndexOf(str, length());
- }
-
- @Override
- public int lastIndexOf(final CharSequence str, final int fromIndex) {
- return lastIndexOf(0, length(), str, 0, str.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param fromIndex the index to begin searching from.
- * @return The index, or -1 if not found.
- * @see java.lang.String#lastIndexOf(char[], int, int, String, int)
- */
- int lastIndexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int fromIndex) {
- return lastIndexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param targetOffset offset of the target sequence.
- * @param targetCount count of the target sequence.
- * @param fromIndex the index to begin searching from.
- * @return The index, or -1 if not found.
- * @see java.lang.String#lastIndexOf(char[], int, int, char[], int, int, int)
- */
- int lastIndexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int targetOffset,
- final int targetCount, final int fromIndex) {
- /*
- * Check arguments; return immediately where possible. For
- * consistency, don't check for null str.
- */
- final int rightIndex = sourceCount - targetCount;
- if (fromIndex < 0) {
- return -1;
- }
- int fromIndexAdjusted = fromIndex;
- if (fromIndex > rightIndex) {
- fromIndexAdjusted = rightIndex;
- }
- /* Empty sequence always matches. */
- if (targetCount == 0) {
- return fromIndexAdjusted;
- }
-
- final int strLastIndex = targetOffset + targetCount - 1;
- final char strLastChar = target.charAt(strLastIndex);
- final int min = sourceOffset + targetCount - 1;
- int i = min + fromIndexAdjusted;
-
- startSearchForLastChar:
- while (true) {
- while (i >= min && byteAt(i) != strLastChar) {
- i--;
- }
- if (i < min) {
- return -1;
- }
- int j = i - 1;
- final int start = j - (targetCount - 1);
- int k = strLastIndex - 1;
-
- while (j > start) {
- if (byteAt(j--) != target.charAt(k--)) {
- i--;
- continue startSearchForLastChar;
- }
- }
- return start - sourceOffset + 1;
- }
- }
-
- @Override
- public int lastIndexOf(final ByteSequence str) {
- return lastIndexOf(str, length());
- }
-
- @Override
- public int lastIndexOf(final ByteSequence str, final int fromIndex) {
- return lastIndexOf(0, length(), str, 0, str.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param fromIndex the index to begin searching from.
- * @return The index, or -1 if not found.
- * @see java.lang.String#lastIndexOf(char[], int, int, String, int)
- */
- int lastIndexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int fromIndex) {
- return lastIndexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
- }
-
- /**
- * Used for searches.
- * The source is the sequence being searched, and the target is the sequence being searched for.
- *
- * @param sourceOffset offset of the source sequence.
- * @param sourceCount count of the source sequence.
- * @param target the characters being searched for.
- * @param targetOffset offset of the target sequence.
- * @param targetCount count of the target sequence.
- * @param fromIndex the index to begin searching from.
- * @return The index, or -1 if not found.
- * @see java.lang.String#lastIndexOf(char[], int, int, char[], int, int, int)
- */
- int lastIndexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int targetOffset,
- final int targetCount, final int fromIndex) {
- /*
- * Check arguments; return immediately where possible. For
- * consistency, don't check for null str.
- */
- final int rightIndex = sourceCount - targetCount;
- if (fromIndex < 0) {
- return -1;
- }
- int fromIndexAdjusted = fromIndex;
- if (fromIndex > rightIndex) {
- fromIndexAdjusted = rightIndex;
- }
- /* Empty sequence always matches. */
- if (targetCount == 0) {
- return fromIndexAdjusted;
- }
-
- final int strLastIndex = targetOffset + targetCount - 1;
- final byte strLastChar = target.byteAt(strLastIndex);
- final int min = sourceOffset + targetCount - 1;
- int i = min + fromIndexAdjusted;
-
- startSearchForLastChar:
- while (true) {
- while (i >= min && byteAt(i) != strLastChar) {
- i--;
- }
- if (i < min) {
- return -1;
- }
- int j = i - 1;
- final int start = j - (targetCount - 1);
- int k = strLastIndex - 1;
-
- while (j > start) {
- if (byteAt(j--) != target.byteAt(k--)) {
- i--;
- continue startSearchForLastChar;
- }
- }
- return start - sourceOffset + 1;
- }
- }
-
- @Override
- public int countWhitespace(final int start) {
- int count = 0;
- int index = start;
- while (index < length()
- && WHITESPACE_CHARS.indexOf(byteAt(index)) < 0) {
- count ++;
- index ++;
- }
- return count;
- }
-
- @Override
- public int findStartOfLine(final int start) {
- int currIndex = start;
- while (true) {
- if (currIndex >= length()) {
- return -1;
- }
- if (isStartOfLine(currIndex)) {
- return currIndex;
- }
- currIndex ++;
- }
- }
-
- @Override
- public boolean isStartOfLine(final int start) {
- switch (start) {
- case 0: return true;
- default: {
- if (byteAt(start - 1) == '\r') {
- if (byteAt(start) == '\n') {
- return false;
- } else {
- return true;
- }
- } else if (byteAt(start - 1) == '\n') {
- return true;
- }
- return false;
- }
- }
- }
-
- @Override
- public ByteSequencePlus readCurrentLine(final int start) {
- if (start >= length()) {
- return null;
- }
- int end = start + 1;
- while (end < length()) {
- final byte theByte = byteAt(end);
- if (theByte == '\r'
- || theByte == '\n') {
- break;
- }
- end ++;
- }
- return subSequence(start, end);
- }
-
- @Override
- public ByteSequencePlus readNextLine(final int start) {
- final int startOfNextLine = findStartOfLine(start + 1);
- return readCurrentLine(startOfNextLine);
- }
-
- @Override
- public ByteSequencePlus readWord(final int start) {
- int trueStart = start;
- while (trueStart < length()
- && WHITESPACE_CHARS.indexOf(byteAt(trueStart)) > -1) {
- trueStart ++;
- }
- if (trueStart >= length()) {
- return null;
- }
- int end = trueStart;
- while (end < length()
- && WHITESPACE_CHARS.indexOf(byteAt(end)) < 0) {
- end ++;
- }
- if (end == trueStart) {
- return null;
- }
- return subSequence(trueStart, end);
- }
-
- @Override
- public ByteSequencePlus readWord(final int start, final int sequence) {
- int toSkip = sequence - 1;
- int currentStart = start;
- ByteSequencePlus word = readWord(currentStart);
- if (word == null) {
- return null;
- }
- while (toSkip > 0) {
- currentStart += word.length();
- currentStart += countWhitespace(currentStart);
- word = readWord(currentStart);
- if (word == null) {
- return null;
- }
- toSkip --;
- }
- return word;
- }
-
- @Override
- public abstract ByteSequencePlus subSequence(int start, int end);
-
- @Override
- public boolean canParseByte() {
- try {
- parseByte();
- return true;
- } catch (final NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public byte parseByte() {
- return Byte.parseByte(toAscii());
- }
-
- @Override
- public byte parseByte(final int radix) {
- return Byte.parseByte(toAscii(), radix);
- }
-
- @Override
- public boolean canParseShort() {
- try {
- parseShort();
- return true;
- } catch (final NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public short parseShort() {
- return Short.parseShort(toAscii());
- }
-
- @Override
- public short parseShort(final int radix) {
- return Short.parseShort(toAscii());
- }
-
- @Override
- public boolean canParseInt() {
- try {
- parseInt();
- return true;
- } catch (final NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public int parseInt() {
- return Integer.parseInt(toAscii());
- }
-
- @Override
- public int parseInt(final int radix) {
- return Integer.parseInt(toAscii());
- }
-
- @Override
- public boolean canParseLong() {
- try {
- parseLong();
- return true;
- } catch (final NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public long parseLong() {
- return Long.parseLong(toAscii());
- }
-
- @Override
- public long parseLong(final int radix) {
- return Long.parseLong(toAscii());
- }
-
- @Override
- public boolean canParseDecimal() {
- try {
- parseDecimal();
- return true;
- } catch (final NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public BigDecimal parseDecimal() {
- return new BigDecimal(toAscii());
- }
-
- @Override
- public void writeTo(final OutputStream output) throws IOException {
- for (int index = 0; index < length(); index ++) {
- final byte theByte = byteAt(index);
- output.write(theByte);
- }
- }
-
- @Override
- public ByteArray toHexByteSequence() {
- final byte[] outBytes = new byte[length() * 2];
- int outIndex = 0;
- for (int index = 0; index < length(); index ++) {
- final byte theByte = byteAt(index);
- final byte highNibble = ByteUtils.toHexCharHigh(theByte);
- outBytes[outIndex] = highNibble;
- outIndex ++;
- final byte lowNibble = ByteUtils.toHexCharLow(theByte);
- outBytes[outIndex] = lowNibble;
- outIndex ++;
- }
- return new ByteArray(outBytes);
- }
-
- @Override
- public ByteSequencePlus asPlus() {
- return this;
- }
-
- @Override
- public BytePrimitiveIterator iterator() {
- return new ByteSequenceIterator(this);
- }
-
- @Override
- public BytePrimitiveIterator iteratorReverse() {
- return new ByteSequenceIterator(this, true);
- }
-
- @Override
- public byte firstElement() {
- return byteAt(0);
- }
-
- @Override
- public byte lastElement() {
- return byteAt(length() - 1);
- }
-
- @Override
- public boolean isEmpty() {
- return this.length() < 1;
- }
-
-}
Copied: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java (from rev 13812, trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java)
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java (rev 0)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
@@ -0,0 +1,775 @@
+/*
+ * Copyright 2020 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.primitive.sequence;
+
+import org.foray.primitive.ByteUtils;
+
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.BytePrimitiveIterator;
+import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.primitive.sequence.ByteSequencePlus;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.math.BigDecimal;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Abstract superclass for byte sequence classes.
+ *
+ * Note that many of the methods in this class were adapted from {@link java.lang.String}.
+ */
+public abstract class AbstractByteSequence4a extends AbstractPrimitiveSequence implements ByteSequencePlus {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = -7127309629480150165L;
+
+ /** Byte array containing all whitespace characters. */
+ private static final ByteArray WHITESPACE_CHARS = new ByteArray(" \n\r\t");
+
+ @Override
+ public String toString() {
+ return toAscii();
+ }
+
+ @Override
+ public String toString(final java.nio.charset.Charset charset) {
+ return new String(toArray(), charset);
+ }
+
+ @Override
+ public String toAscii() {
+ return toString(StandardCharsets.US_ASCII);
+ }
+
+ @Override
+ public CharSequence charSubSequence(final int start, final int end) {
+ return subSequence(start, end).toAscii();
+ }
+
+ @Override
+ public CharSequence charSubSequence(final int start, final int end, final Charset charset) {
+ return subSequence(start, end).toString(charset);
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return altEquals(other);
+ }
+
+ @Override
+ public int hashCode() {
+ return altHashCode();
+ }
+
+ @Override
+ public String difference(final Object other) {
+ if (other == null) {
+ return "Comparison object is null.";
+ }
+ if (! (other instanceof ByteSequence)) {
+ return "Comparison object is not a byte sequence.";
+ }
+ final ByteSequence otherSequence = (ByteSequence) other;
+
+ final StringBuilder builder = new StringBuilder();
+ if (length() != otherSequence.length()) {
+ builder.append(String.format("Lengths are different: this %d, other %d.", this.length(),
+ otherSequence.length()));
+ }
+
+ final int maxIndex = Math.min(this.length(), otherSequence.length());
+ int diffIndex = -1;
+ for (int index = 0; index < maxIndex; index ++) {
+ if (byteAt(index) != otherSequence.byteAt(index)) {
+ diffIndex = index;
+ break;
+ }
+ }
+ if (diffIndex < 0
+ && length() != otherSequence.length()) {
+ diffIndex = maxIndex + 1;
+ }
+
+ if (diffIndex > -1) {
+ if (builder.length() > 0) {
+ builder.append(" ");
+ }
+ builder.append(String.format("First difference is at index %d.", diffIndex));
+ }
+
+ return builder.toString();
+ }
+
+ @Override
+ public int compareToLtR(final ByteSequence other) {
+ final int len1 = length();
+ final int len2 = other.length();
+ final int lim = Math.min(len1, len2);
+
+ int k = 0;
+ while (k < lim) {
+ final byte byte1 = byteAt(k);
+ final byte byte2 = other.byteAt(k);
+ if (byte1 != byte2) {
+ return byte1 - byte2;
+ }
+ k++;
+ }
+ return len1 - len2;
+ }
+
+ @Override
+ public int indexOf(final int aByte) {
+ return indexOf(aByte, 0);
+ }
+
+ @Override
+ public int indexOf(final int aByte, final int fromIndex) {
+ if (aByte < Byte.MIN_VALUE
+ || aByte > Byte.MAX_VALUE) {
+ return -1;
+ }
+ final int max = length();
+ int startIndex = fromIndex;
+ if (fromIndex < 0) {
+ startIndex = 0;
+ } else if (fromIndex >= max) {
+ return -1;
+ }
+ for (int i = startIndex; i < max; i++) {
+ if (byteAt(i) == aByte) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public int indexOf(final CharSequence str) {
+ return indexOf(str, 0);
+ }
+
+ @Override
+ public int indexOf(final CharSequence str, final int fromIndex) {
+ return indexOf(0, length(), str, 0, str.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ * @return The index where {@code target} was found, or -1 if not found.
+ * @see java.lang.String#indexOf(char[], int, int, String, int)
+ */
+ int indexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int fromIndex) {
+ return indexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param targetOffset offset of the target sequence.
+ * @param targetCount count of the target sequence.
+ * @param fromIndex the index to begin searching from.
+ * @return The index where {@code target} was found, or -1 if not found.
+ * @see java.lang.String#indexOf(char[], int, int, char[], int, int, int)
+ */
+ int indexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int targetOffset,
+ final int targetCount, final int fromIndex) {
+ if (fromIndex >= sourceCount) {
+ return targetCount == 0 ? sourceCount : -1;
+ }
+ int startIndex = fromIndex;
+ if (fromIndex < 0) {
+ startIndex = 0;
+ }
+ if (targetCount == 0) {
+ return startIndex;
+ }
+
+ final char first = target.charAt(targetOffset);
+ final int max = sourceOffset + (sourceCount - targetCount);
+
+ for (int i = sourceOffset + startIndex; i <= max; i++) {
+ /* Look for first character. */
+ if (byteAt(i) != first) {
+ while (++i <= max && byteAt(i) != first) { }
+ }
+
+ /* Found first character, now look at the rest of v2 */
+ if (i <= max) {
+ int j = i + 1;
+ final int end = j + targetCount - 1;
+ for (int k = targetOffset + 1; j < end && byteAt(j) == target.charAt(k); j++, k++) { }
+
+ if (j == end) {
+ /* Found whole sequence. */
+ return i - sourceOffset;
+ }
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public int indexOf(final ByteSequence str) {
+ return indexOf(str, 0);
+ }
+
+ @Override
+ public int indexOf(final ByteSequence str, final int fromIndex) {
+ return indexOf(0, length(), str, 0, str.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ * @return The index where {@code target} was found, or -1 if not found.
+ * @see java.lang.String#indexOf(char[], int, int, String, int)
+ */
+ int indexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int fromIndex) {
+ return indexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param targetOffset offset of the target sequence.
+ * @param targetCount count of the target sequence.
+ * @param fromIndex the index to begin searching from.
+ * @return The index where {@code target} was found, or -1 if not found.
+ * @see java.lang.String#indexOf(char[], int, int, char[], int, int, int)
+ */
+ int indexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int targetOffset,
+ final int targetCount, final int fromIndex) {
+ if (fromIndex >= sourceCount) {
+ return targetCount == 0 ? sourceCount : -1;
+ }
+ int startIndex = fromIndex;
+ if (fromIndex < 0) {
+ startIndex = 0;
+ }
+ if (targetCount == 0) {
+ return startIndex;
+ }
+
+ final byte first = target.byteAt(targetOffset);
+ final int max = sourceOffset + (sourceCount - targetCount);
+
+ for (int i = sourceOffset + startIndex; i <= max; i++) {
+ /* Look for first character. */
+ if (byteAt(i) != first) {
+ while (++i <= max && byteAt(i) != first) { }
+ }
+
+ /* Found first character, now look at the rest of v2 */
+ if (i <= max) {
+ int j = i + 1;
+ final int end = j + targetCount - 1;
+ for (int k = targetOffset + 1; j < end && byteAt(j) == target.byteAt(k); j++, k++) { }
+
+ if (j == end) {
+ /* Found whole sequence. */
+ return i - sourceOffset;
+ }
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public boolean contains(final byte testByte) {
+ return indexOf(testByte) > -1;
+ }
+
+ @Override
+ public int lastIndexOf(final int aByte) {
+ return lastIndexOf(aByte, length() - 1);
+ }
+
+ @Override
+ public int lastIndexOf(final int aByte, final int fromIndex) {
+ int i = Math.min(fromIndex, length() - 1);
+ for (; i >= 0; i--) {
+ if (byteAt(i) == aByte) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public int lastIndexOf(final CharSequence str) {
+ return lastIndexOf(str, length());
+ }
+
+ @Override
+ public int lastIndexOf(final CharSequence str, final int fromIndex) {
+ return lastIndexOf(0, length(), str, 0, str.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ * @return The index, or -1 if not found.
+ * @see java.lang.String#lastIndexOf(char[], int, int, String, int)
+ */
+ int lastIndexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int fromIndex) {
+ return lastIndexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param targetOffset offset of the target sequence.
+ * @param targetCount count of the target sequence.
+ * @param fromIndex the index to begin searching from.
+ * @return The index, or -1 if not found.
+ * @see java.lang.String#lastIndexOf(char[], int, int, char[], int, int, int)
+ */
+ int lastIndexOf(final int sourceOffset, final int sourceCount, final CharSequence target, final int targetOffset,
+ final int targetCount, final int fromIndex) {
+ /*
+ * Check arguments; return immediately where possible. For
+ * consistency, don't check for null str.
+ */
+ final int rightIndex = sourceCount - targetCount;
+ if (fromIndex < 0) {
+ return -1;
+ }
+ int fromIndexAdjusted = fromIndex;
+ if (fromIndex > rightIndex) {
+ fromIndexAdjusted = rightIndex;
+ }
+ /* Empty sequence always matches. */
+ if (targetCount == 0) {
+ return fromIndexAdjusted;
+ }
+
+ final int strLastIndex = targetOffset + targetCount - 1;
+ final char strLastChar = target.charAt(strLastIndex);
+ final int min = sourceOffset + targetCount - 1;
+ int i = min + fromIndexAdjusted;
+
+ startSearchForLastChar:
+ while (true) {
+ while (i >= min && byteAt(i) != strLastChar) {
+ i--;
+ }
+ if (i < min) {
+ return -1;
+ }
+ int j = i - 1;
+ final int start = j - (targetCount - 1);
+ int k = strLastIndex - 1;
+
+ while (j > start) {
+ if (byteAt(j--) != target.charAt(k--)) {
+ i--;
+ continue startSearchForLastChar;
+ }
+ }
+ return start - sourceOffset + 1;
+ }
+ }
+
+ @Override
+ public int lastIndexOf(final ByteSequence str) {
+ return lastIndexOf(str, length());
+ }
+
+ @Override
+ public int lastIndexOf(final ByteSequence str, final int fromIndex) {
+ return lastIndexOf(0, length(), str, 0, str.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ * @return The index, or -1 if not found.
+ * @see java.lang.String#lastIndexOf(char[], int, int, String, int)
+ */
+ int lastIndexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int fromIndex) {
+ return lastIndexOf(sourceOffset, sourceCount, target, 0, target.length(), fromIndex);
+ }
+
+ /**
+ * Used for searches.
+ * The source is the sequence being searched, and the target is the sequence being searched for.
+ *
+ * @param sourceOffset offset of the source sequence.
+ * @param sourceCount count of the source sequence.
+ * @param target the characters being searched for.
+ * @param targetOffset offset of the target sequence.
+ * @param targetCount count of the target sequence.
+ * @param fromIndex the index to begin searching from.
+ * @return The index, or -1 if not found.
+ * @see java.lang.String#lastIndexOf(char[], int, int, char[], int, int, int)
+ */
+ int lastIndexOf(final int sourceOffset, final int sourceCount, final ByteSequence target, final int targetOffset,
+ final int targetCount, final int fromIndex) {
+ /*
+ * Check arguments; return immediately where possible. For
+ * consistency, don't check for null str.
+ */
+ final int rightIndex = sourceCount - targetCount;
+ if (fromIndex < 0) {
+ return -1;
+ }
+ int fromIndexAdjusted = fromIndex;
+ if (fromIndex > rightIndex) {
+ fromIndexAdjusted = rightIndex;
+ }
+ /* Empty sequence always matches. */
+ if (targetCount == 0) {
+ return fromIndexAdjusted;
+ }
+
+ final int strLastIndex = targetOffset + targetCount - 1;
+ final byte strLastChar = target.byteAt(strLastIndex);
+ final int min = sourceOffset + targetCount - 1;
+ int i = min + fromIndexAdjusted;
+
+ startSearchForLastChar:
+ while (true) {
+ while (i >= min && byteAt(i) != strLastChar) {
+ i--;
+ }
+ if (i < min) {
+ return -1;
+ }
+ int j = i - 1;
+ final int start = j - (targetCount - 1);
+ int k = strLastIndex - 1;
+
+ while (j > start) {
+ if (byteAt(j--) != target.byteAt(k--)) {
+ i--;
+ continue startSearchForLastChar;
+ }
+ }
+ return start - sourceOffset + 1;
+ }
+ }
+
+ @Override
+ public int countWhitespace(final int start) {
+ int count = 0;
+ int index = start;
+ while (index < length()
+ && WHITESPACE_CHARS.indexOf(byteAt(index)) < 0) {
+ count ++;
+ index ++;
+ }
+ return count;
+ }
+
+ @Override
+ public int findStartOfLine(final int start) {
+ int currIndex = start;
+ while (true) {
+ if (currIndex >= length()) {
+ return -1;
+ }
+ if (isStartOfLine(currIndex)) {
+ return currIndex;
+ }
+ currIndex ++;
+ }
+ }
+
+ @Override
+ public boolean isStartOfLine(final int start) {
+ switch (start) {
+ case 0: return true;
+ default: {
+ if (byteAt(start - 1) == '\r') {
+ if (byteAt(start) == '\n') {
+ return false;
+ } else {
+ return true;
+ }
+ } else if (byteAt(start - 1) == '\n') {
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public ByteSequencePlus readCurrentLine(final int start) {
+ if (start >= length()) {
+ return null;
+ }
+ int end = start + 1;
+ while (end < length()) {
+ final byte theByte = byteAt(end);
+ if (theByte == '\r'
+ || theByte == '\n') {
+ break;
+ }
+ end ++;
+ }
+ return subSequence(start, end);
+ }
+
+ @Override
+ public ByteSequencePlus readNextLine(final int start) {
+ final int startOfNextLine = findStartOfLine(start + 1);
+ return readCurrentLine(startOfNextLine);
+ }
+
+ @Override
+ public ByteSequencePlus readWord(final int start) {
+ int trueStart = start;
+ while (trueStart < length()
+ && WHITESPACE_CHARS.indexOf(byteAt(trueStart)) > -1) {
+ trueStart ++;
+ }
+ if (trueStart >= length()) {
+ return null;
+ }
+ int end = trueStart;
+ while (end < length()
+ && WHITESPACE_CHARS.indexOf(byteAt(end)) < 0) {
+ end ++;
+ }
+ if (end == trueStart) {
+ return null;
+ }
+ return subSequence(trueStart, end);
+ }
+
+ @Override
+ public ByteSequencePlus readWord(final int start, final int sequence) {
+ int toSkip = sequence - 1;
+ int currentStart = start;
+ ByteSequencePlus word = readWord(currentStart);
+ if (word == null) {
+ return null;
+ }
+ while (toSkip > 0) {
+ currentStart += word.length();
+ currentStart += countWhitespace(currentStart);
+ word = readWord(currentStart);
+ if (word == null) {
+ return null;
+ }
+ toSkip --;
+ }
+ return word;
+ }
+
+ @Override
+ public abstract ByteSequencePlus subSequence(int start, int end);
+
+ @Override
+ public boolean canParseByte() {
+ try {
+ parseByte();
+ return true;
+ } catch (final NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public byte parseByte() {
+ return Byte.parseByte(toAscii());
+ }
+
+ @Override
+ public byte parseByte(final int radix) {
+ return Byte.parseByte(toAscii(), radix);
+ }
+
+ @Override
+ public boolean canParseShort() {
+ try {
+ parseShort();
+ return true;
+ } catch (final NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public short parseShort() {
+ return Short.parseShort(toAscii());
+ }
+
+ @Override
+ public short parseShort(final int radix) {
+ return Short.parseShort(toAscii());
+ }
+
+ @Override
+ public boolean canParseInt() {
+ try {
+ parseInt();
+ return true;
+ } catch (final NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public int parseInt() {
+ return Integer.parseInt(toAscii());
+ }
+
+ @Override
+ public int parseInt(final int radix) {
+ return Integer.parseInt(toAscii());
+ }
+
+ @Override
+ public boolean canParseLong() {
+ try {
+ parseLong();
+ return true;
+ } catch (final NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public long parseLong() {
+ return Long.parseLong(toAscii());
+ }
+
+ @Override
+ public long parseLong(final int radix) {
+ return Long.parseLong(toAscii());
+ }
+
+ @Override
+ public boolean canParseDecimal() {
+ try {
+ parseDecimal();
+ return true;
+ } catch (final NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public BigDecimal parseDecimal() {
+ return new BigDecimal(toAscii());
+ }
+
+ @Override
+ public void writeTo(final OutputStream output) throws IOException {
+ for (int index = 0; index < length(); index ++) {
+ final byte theByte = byteAt(index);
+ output.write(theByte);
+ }
+ }
+
+ @Override
+ public ByteArray toHexByteSequence() {
+ final byte[] outBytes = new byte[length() * 2];
+ int outIndex = 0;
+ for (int index = 0; index < length(); index ++) {
+ final byte theByte = byteAt(index);
+ final byte highNibble = ByteUtils.toHexCharHigh(theByte);
+ outBytes[outIndex] = highNibble;
+ outIndex ++;
+ final byte lowNibble = ByteUtils.toHexCharLow(theByte);
+ outBytes[outIndex] = lowNibble;
+ outIndex ++;
+ }
+ return new ByteArray(outBytes);
+ }
+
+ @Override
+ public ByteSequencePlus asPlus() {
+ return this;
+ }
+
+ @Override
+ public BytePrimitiveIterator iterator() {
+ return new ByteSequenceIterator(this);
+ }
+
+ @Override
+ public BytePrimitiveIterator iteratorReverse() {
+ return new ByteSequenceIterator(this, true);
+ }
+
+ @Override
+ public byte firstElement() {
+ return byteAt(0);
+ }
+
+ @Override
+ public byte lastElement() {
+ return byteAt(length() - 1);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return this.length() < 1;
+ }
+
+}
Deleted: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java 2025-06-04 11:23:54 UTC (rev 13813)
@@ -1,110 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.primitive.sequence;
-
-import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
-import org.axsl.primitive.sequence.CharPrimitiveIterator;
-import org.axsl.primitive.sequence.CharSequenceMutable;
-import org.axsl.primitive.sequence.CharSequencePlus;
-import org.axsl.primitive.sequence.CharSequenceUtility;
-
-/**
- * Abstract superclass for implementations of {@link CharSequencePlus}.
- */
-public abstract class AbstractCharSequence extends AbstractPrimitiveSequence implements CharSequencePlus {
-
- /** Constant needed for serialization. */
- private static final long serialVersionUID = -4790770925304512788L;
-
- @Override
- public int indexOf(final char aChar) {
- for (int index = 0; index < length(); index ++) {
- final int foundChar = charAt(index);
- if (foundChar == aChar) {
- return index;
- }
- }
- return -1;
- }
-
- @Override
- public boolean contains(final char theInt) {
- return indexOf(theInt) > -1;
- }
-
- @Override
- public CharPrimitiveIterator iterator() {
- return new CharSequenceIterator(this);
- }
-
- @Override
- public CharPrimitiveIterator iteratorReverse() {
- return new CharSequenceIterator(this, true);
- }
-
- @Override
- public CharSequencePlus asPlus() {
- return this;
- }
-
- /**
- * Provides an implementation of {@link CharSequenceMutable} from a specified {@link CharSequence}, recasting the
- * specified sequence if possible, otherwise copying its content into a new mutable instance.
- * @param charSequence The sequence for which a mutable instance is needed.
- * @return A mutable sequence.
- */
- public static CharSequenceMutable fromCharSequence(final CharSequence charSequence) {
- if (charSequence == null) {
- return new CharArrayBuilder();
- }
- final CharSequenceMutable mutable = CharSequenceUtility.asMutable(charSequence);
- if (mutable != null) {
- return mutable;
- }
- final CharArrayBuilder builder = new CharArrayBuilder(charSequence.length());
- builder.append(charSequence);
- return builder;
- }
-
- @Override
- public char firstElement() {
- return charAt(0);
- }
-
- @Override
- public char lastElement() {
- return charAt(length() - 1);
- }
-
- @Override
- public boolean isEmpty() {
- return this.length() < 1;
- }
-
-}
Copied: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java (from rev 13812, trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java)
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java (rev 0)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence4a.java 2025-06-04 11:23:54 UTC (rev 13813)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2020 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.primitive.sequence;
+
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
+import org.axsl.primitive.sequence.CharPrimitiveIterator;
+import org.axsl.primitive.sequence.CharSequenceMutable;
+import org.axsl.primitive.sequence.CharSequencePlus;
+import org.axsl.primitive.sequence.CharSequenceUtility;
+
+/**
+ * Abstract superclass for implementations of {@link CharSequencePlus}.
+ */
+public abstract class AbstractCharSequence4a extends AbstractPrimitiveSequence implements CharSequencePlus {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = -4790770925304512788L;
+
+ @Override
+ pub...
[truncated message content] |
|
From: <vic...@us...> - 2025-06-04 11:19:11
|
Revision: 13812
http://sourceforge.net/p/foray/code/13812
Author: victormote
Date: 2025-06-04 11:19:00 +0000 (Wed, 04 Jun 2025)
Log Message:
-----------
Conform to aXSL change: Move common primitive sequence code to aXSL.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence.java
Removed Paths:
-------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractSequence.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -30,6 +30,7 @@
import org.foray.primitive.ByteUtils;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.BytePrimitiveIterator;
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -45,7 +46,7 @@
*
* Note that many of the methods in this class were adapted from {@link java.lang.String}.
*/
-public abstract class AbstractByteSequence extends AbstractSequence implements ByteSequencePlus {
+public abstract class AbstractByteSequence extends AbstractPrimitiveSequence implements ByteSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -7127309629480150165L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractCharSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.CharPrimitiveIterator;
import org.axsl.primitive.sequence.CharSequenceMutable;
import org.axsl.primitive.sequence.CharSequencePlus;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link CharSequencePlus}.
*/
-public abstract class AbstractCharSequence extends AbstractSequence implements CharSequencePlus {
+public abstract class AbstractCharSequence extends AbstractPrimitiveSequence implements CharSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -4790770925304512788L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractDoubleSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.DoublePrimitiveIterator;
import org.axsl.primitive.sequence.DoubleSequence;
import org.axsl.primitive.sequence.DoubleSequenceMutable;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link DoubleSequencePlus}.
*/
-public abstract class AbstractDoubleSequence extends AbstractSequence implements DoubleSequencePlus {
+public abstract class AbstractDoubleSequence extends AbstractPrimitiveSequence implements DoubleSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -460518736372819472L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractFloatSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.FloatPrimitiveIterator;
import org.axsl.primitive.sequence.FloatSequence;
import org.axsl.primitive.sequence.FloatSequenceMutable;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link FloatSequencePlus}.
*/
-public abstract class AbstractFloatSequence extends AbstractSequence implements FloatSequencePlus {
+public abstract class AbstractFloatSequence extends AbstractPrimitiveSequence implements FloatSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = 5696774869086963028L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractIntSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.IntPrimitiveIterator;
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link IntSequencePlus}.
*/
-public abstract class AbstractIntSequence extends AbstractSequence implements IntSequencePlus {
+public abstract class AbstractIntSequence extends AbstractPrimitiveSequence implements IntSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -7886656099618775680L;
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractLongSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.LongPrimitiveIterator;
import org.axsl.primitive.sequence.LongSequence;
import org.axsl.primitive.sequence.LongSequenceMutable;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link LongSequencePlus}.
*/
-public abstract class AbstractLongSequence extends AbstractSequence implements LongSequencePlus {
+public abstract class AbstractLongSequence extends AbstractPrimitiveSequence implements LongSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -6030416496206309157L;
Deleted: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2022 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.primitive.sequence;
-
-/**
- * Common code for sequences.
- */
-public class AbstractSequence {
-
- /** The template for the message for this exception. */
- private static final String FORMAT = "Index = %d, Size = %d";
-
- /**
- * Always throws an IndexOutOfBoundsException with a helpful message.
- * @param offendingIndex The index value that is out-of-bounds.
- * @param sizeOfOffendedItem The size of the indexed object whose range was violated.
- */
- public void throwIndexOutOfBoundsException(final int offendingIndex, final int sizeOfOffendedItem) {
- final String message = String.format(FORMAT, offendingIndex, sizeOfOffendedItem);
- throw new IndexOutOfBoundsException(message);
- }
-
-}
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractShortSequence.java 2025-06-04 11:19:00 UTC (rev 13812)
@@ -28,6 +28,7 @@
package org.foray.primitive.sequence;
+import org.axsl.primitive.sequence.AbstractPrimitiveSequence;
import org.axsl.primitive.sequence.ShortPrimitiveIterator;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.primitive.sequence.ShortSequenceMutable;
@@ -36,7 +37,7 @@
/**
* Abstract superclass for implementations of {@link ShortSequencePlus}.
*/
-public abstract class AbstractShortSequence extends AbstractSequence implements ShortSequencePlus {
+public abstract class AbstractShortSequence extends AbstractPrimitiveSequence implements ShortSequencePlus {
/** Constant needed for serialization. */
private static final long serialVersionUID = -9026237362654665973L;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-03 16:05:20
|
Revision: 13811
http://sourceforge.net/p/foray/code/13811
Author: victormote
Date: 2025-06-03 16:05:07 +0000 (Tue, 03 Jun 2025)
Log Message:
-----------
Fix hashcode problem in ByteArray using new methods in ByteSequence.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/readonly/ReadOnlySystemDict.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-03 11:37:21 UTC (rev 13810)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/AbstractByteSequence.java 2025-06-03 16:05:07 UTC (rev 13811)
@@ -80,25 +80,15 @@
@Override
public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (! (other instanceof ByteSequence)) {
- return false;
- }
- final ByteSequence otherSequence = (ByteSequence) other;
- if (length() != otherSequence.length()) {
- return false;
- }
- for (int index = 0; index < length(); index ++) {
- if (byteAt(index) != otherSequence.byteAt(index)) {
- return false;
- }
- }
- return true;
+ return altEquals(other);
}
@Override
+ public int hashCode() {
+ return altHashCode();
+ }
+
+ @Override
public String difference(final Object other) {
if (other == null) {
return "Comparison object is null.";
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-03 11:37:21 UTC (rev 13810)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-03 16:05:07 UTC (rev 13811)
@@ -107,11 +107,6 @@
this(charSequence.toString().getBytes(StandardCharsets.US_ASCII));
}
- @Override
- public int hashCode() {
- return this.array.hashCode();
- }
-
/**
* Converts an existing byte sequence to a byte array, creating the byte array only if necessary.
* @param sequence The sequence to be converted.
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/readonly/ReadOnlySystemDict.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/readonly/ReadOnlySystemDict.java 2025-06-03 11:37:21 UTC (rev 13810)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/readonly/ReadOnlySystemDict.java 2025-06-03 16:05:07 UTC (rev 13811)
@@ -35,11 +35,11 @@
import org.axsl.primitive.sequence.ByteSequence;
/**
- * PsSystemDict implementation that provides no painting or other rendering, but that is suitable
- * for simple parsing of a PostScript file.
+ * PsSystemDict implementation that provides no painting or other rendering, but that is suitable for simple parsing of
+ * a PostScript file.
* This implementation is suitable for parsing Type1 fonts, for example.
- * It is "final" and should not be extended: instead extend the abstract {@link PsSystemDict4a}, which
- * should provide identical capabilities.
+ * It is "final" and should not be extended: instead extend the abstract {@link PsSystemDict4a}, which should provide
+ * identical capabilities.
*/
public final class ReadOnlySystemDict extends PsSystemDict4a {
@@ -63,8 +63,8 @@
public void linetoDevice(final PsNumber x, final PsNumber y) { }
@Override
- public void curvetoDevice(final double x1, final double y1, final double x2,
- final double y2, final double x3, final double y3) { }
+ public void curvetoDevice(final double x1, final double y1, final double x2, final double y2, final double x3,
+ final double y3) { }
@Override
public void fillDevice() { }
@@ -76,12 +76,10 @@
public void setgrayDevice(final float grayValue) { }
@Override
- public void setcmykcolorDevice(final float cyan, final float magenta,
- final float yellow, final float black) { }
+ public void setcmykcolorDevice(final float cyan, final float magenta, final float yellow, final float black) { }
@Override
- public void setrgbcolorDevice(final float red, final float green,
- final float blue) { }
+ public void setrgbcolorDevice(final float red, final float green, final float blue) { }
@Override
public ByteSequence getOutput() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-03 11:37:24
|
Revision: 13810
http://sourceforge.net/p/foray/code/13810
Author: victormote
Date: 2025-06-03 11:37:21 +0000 (Tue, 03 Jun 2025)
Log Message:
-----------
Have PsName wrap a byte array instead of a char array.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsOperator.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -35,7 +35,7 @@
import org.axsl.primitive.sequence.ByteSequenceMutable;
import java.io.Serializable;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -99,12 +99,12 @@
/**
* Constructor for a String or other CharSequence.
- * The chars in the sequence will be converted to bytes using the "US-ASII" Charset.
+ * The chars in the sequence will be converted to bytes using the "US-ASCII" Charset.
* @param charSequence The String or other CharSequence whose character should be converted to bytes and
* wrapped.
*/
public ByteArray(final CharSequence charSequence) {
- this(charSequence.toString().getBytes(Charset.forName("US-ASCII")));
+ this(charSequence.toString().getBytes(StandardCharsets.US_ASCII));
}
@Override
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsDictionary.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -273,7 +273,7 @@
return null;
}
final PsName string = (PsName) object;
- return string.getValue();
+ return string.getValue().toAscii();
}
/**
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -237,12 +237,12 @@
systemDictToUse.setPSInterpreter(this);
// Add the Standard Encoding to the System Dictionary.
PsName name = new PsName("StandardEncoding", false, false);
- EncodingVector encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
+ EncodingVector encoding = EncodingVector4a.getPredefinedEncoding(name.getValue().toAscii());
PsArray array = new PsArray(encoding.getGlyphNames().toArray(), false);
systemDictToUse.addItem(this, name, array);
// Add the ISO Latin 1 Encoding to the System Dictionary.
name = new PsName("ISOLatin1Encoding", false, false);
- encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
+ encoding = EncodingVector4a.getPredefinedEncoding(name.getValue().toAscii());
array = new PsArray(encoding.getGlyphNames().toArray(), false);
systemDictToUse.addItem(this, name, array);
// Add the System Dictionary to the dictionary stack.
@@ -692,7 +692,7 @@
object = PsReal.create(this.tokenBeingBuilt.toArray());
}
if (object == null) {
- object = PsName.create(this.tokenBeingBuilt.toArray());
+ object = PsName.create(this.tokenBeingBuilt.toString());
}
processToken(object);
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -28,6 +28,9 @@
package org.foray.ps;
+import org.foray.primitive.sequence.ByteArray;
+import org.foray.primitive.sequence.ByteArrayBuilder;
+
/**
* Class representing a "name" PostScript object.
* @see "PostScript Language Reference, Section 3.3.8."
@@ -35,7 +38,7 @@
public class PsName implements PsObjectSimple {
/** The encapsulated value for this object. */
- private String value;
+ private ByteArray value;
/** Indicates whether this name is executable. */
private boolean isExecutable;
@@ -44,13 +47,22 @@
private boolean isImmediatelyEvaluated;
/**
- * Constructor.
+ * Constructor for a String.
* @param value The value to encapsulate.
* @param executable Set to true if this object is executable.
* @param immediatelyEvaluated Set to true if this name should be evaluated immediately.
*/
public PsName(final String value, final boolean executable, final boolean immediatelyEvaluated) {
- super();
+ this(new ByteArray(value), executable, immediatelyEvaluated);
+ }
+
+ /**
+ * Constructor for a ByteArray.
+ * @param value The value to encapsulate.
+ * @param executable Set to true if this object is executable.
+ * @param immediatelyEvaluated Set to true if this name should be evaluated immediately.
+ */
+ public PsName(final ByteArray value, final boolean executable, final boolean immediatelyEvaluated) {
this.value = value;
this.isExecutable = executable;
this.isImmediatelyEvaluated = immediatelyEvaluated;
@@ -66,33 +78,29 @@
* @param input The byte array containing the content to be converted to a PsName instance.
* @return A PsName instance, if the input qualifies, otherwise, null.
*/
- public static PsName create(final byte[] input) {
- /*
- * There is not really much validation work to do here that we know of.
- * The input should be checked first to see whether it is a valid
- * number. If it is not a number, then it is a name.
- */
- if (input[0] == PsInterpreter4a.SLASH
- && input.length > 1
- && input[1] == PsInterpreter4a.SLASH) {
- final String name = new String(input, 2, input.length - 2);
- return new PsName(name, false, true);
+ public static PsName create(final String input) {
+ /* Uses the ASCII Charset. */
+ final ByteArrayBuilder builder = new ByteArrayBuilder(input.length());
+ builder.append(input);
+
+ if (builder.byteAt(0) == PsInterpreter4a.SLASH) {
+ if (builder.length() > 1
+ && builder.byteAt(1) == PsInterpreter4a.SLASH) {
+ builder.delete(0, 2);
+ return new PsName(new ByteArray(builder), false, true);
+ } else {
+ builder.delete(0, 1);
+ return new PsName(new ByteArray(builder), false, false);
+ }
}
- if (input[0] == PsInterpreter4a.SLASH) {
- final String name = new String(input, 1, input.length - 1);
- return new PsName(name, false, false);
- }
- return new PsName(new String(input), true, false);
+ return new PsName(new ByteArray(builder), true, false);
}
@Override
public PsObject duplicate() {
- /*
- * PsName is a simple object type, but we are actually storing it in
- * a java composite object, so we need to unwrap it and copy the
- * contents.
- */
- return new PsName(new String(this.value), this.isExecutable, this.isImmediatelyEvaluated);
+ /* PsName is a simple object type, so we need to return a different instance.
+ * The internal byte array is immutable, so we can reuse it. */
+ return new PsName(this.value, this.isExecutable, this.isImmediatelyEvaluated);
}
@Override
@@ -113,8 +121,8 @@
return false;
}
for (int index = 0; index < this.value.length(); index ++) {
- final char myChar = this.value.charAt(index);
- final int otherChar = Byte.toUnsignedInt(psStringObject.getValue().byteAt(index));
+ final byte myChar = this.value.byteAt(index);
+ final byte otherChar = psStringObject.getValue().byteAt(index);
if (myChar != otherChar) {
return false;
}
@@ -166,7 +174,7 @@
* Returns the value.
* @return The value.
*/
- public String getValue() {
+ public ByteArray getValue() {
return this.value;
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsOperator.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsOperator.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsOperator.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -1479,10 +1479,13 @@
/**
* Maps an operator name String to the related PsOperator instance.
- * @param name The String to be evaluated.
+ * @param psName The name to be evaluated.
* @return The PsOperator equivalent of {@code name}.
*/
- public static PsOperator mapNameToEnum(final String name) {
+ public static PsOperator mapNameToEnum(final PsName psName) {
+ /* TODO: The operators are can be overridden. This class needs to be rewritten as a Map instead of a binary
+ * lookup into a hard-coded list. */
+ final String name = psName.getValue().toString();
int low = 0;
int high = PsOperator.OPERATOR_NAMES.length - 1;
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -87,9 +87,9 @@
return false;
}
for (int index = 0; index < this.value.length(); index ++) {
- final int myChar = Byte.toUnsignedInt(getValue().byteAt(index));
- final char otherChar = psNameObject.getValue().charAt(index);
- if (myChar != otherChar) {
+ final int myByte = getValue().byteAt(index);
+ final byte otherByte = psNameObject.getValue().byteAt(index);
+ if (myByte != otherByte) {
return false;
}
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-03 10:40:16 UTC (rev 13809)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-03 11:37:21 UTC (rev 13810)
@@ -100,7 +100,7 @@
if (super.execute(this.interpreter, nameObject)) {
return true;
}
- final PsOperator operator = PsOperator.mapNameToEnum(nameObject.getValue());
+ final PsOperator operator = PsOperator.mapNameToEnum(nameObject);
if (operator == null) {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-03 10:40:19
|
Revision: 13809
http://sourceforge.net/p/foray/code/13809
Author: victormote
Date: 2025-06-03 10:40:16 +0000 (Tue, 03 Jun 2025)
Log Message:
-----------
Conform to aXSL change: Remove unnecessary char-to-byte conversion options.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArrayBuilder.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArrayBuilder.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArrayBuilder.java 2025-06-02 22:42:30 UTC (rev 13808)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArrayBuilder.java 2025-06-03 10:40:16 UTC (rev 13809)
@@ -157,14 +157,6 @@
}
@Override
- public ByteArrayBuilder append(final CharSequence charSequence, final String charsetName) {
- final Charset charset = Charset.forName(charsetName);
- final byte[] bytes = charSequence.toString().getBytes(charset);
- append(bytes);
- return this;
- }
-
- @Override
public ByteArrayBuilder append(final char theChar) {
final Charset charset = Charset.forName("US-ASCII");
return append(theChar, charset);
@@ -177,12 +169,6 @@
return this;
}
- @Override
- public ByteArrayBuilder append(final char theChar, final String charsetName) {
- final Charset charset = Charset.forName(charsetName);
- return append(theChar, charset);
- }
-
/**
* Allocates or uses a specified number of elements (bytes).
* If needed, this method automatically increases the vector's capacity.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-02 22:42:33
|
Revision: 13808
http://sourceforge.net/p/foray/code/13808
Author: victormote
Date: 2025-06-02 22:42:30 +0000 (Mon, 02 Jun 2025)
Log Message:
-----------
Simplify creation of PsInteger and PsReal.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInteger.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsReal.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInteger.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInteger.java 2025-06-02 22:36:32 UTC (rev 13807)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInteger.java 2025-06-02 22:42:30 UTC (rev 13808)
@@ -93,24 +93,20 @@
}
/**
- * Static method to attempt to create a PSInteger instance, if the input
- * qualifies.
- * @param interpreter The parent interpreter.
- * @param input The byte array containing the content to be converted to
- * a PSInteger instance.
+ * Static method to attempt to create a PSInteger instance, if the input qualifies.
+ * @param input The byte array containing the content to be converted to a PSInteger instance.
* @return A PSInteger instance, if the input qualifies, otherwise, null.
*/
- public static PsInteger create(final PsInterpreter4a interpreter,
- final byte[] input) {
+ public static PsInteger create(final byte[] input) {
// First char must be a digit or a sign indicator
if (!isNumeral(input[0]) && !isMember(PsInterpreter4a.SIGN_INDICATOR,
input[0])) {
- return parseRadixNumber(interpreter, input);
+ return parseRadixNumber(input);
}
// Every other char must be a digit
for (int i = 1; i < input.length; i++) {
if (!isNumeral(input[i])) {
- return parseRadixNumber(interpreter, input);
+ return parseRadixNumber(input);
}
}
boolean isPositive = true;
@@ -134,18 +130,12 @@
}
/**
- * Static method to attempt to create a PSInteger instance, if the input
- * qualifies.
- * All radix numbers are positive per PSRM2, Sec. 3.2.2, Subsection
- * "Numbers".
- * @param interpreter the PSInterpreter instance to which the new PSInteger
- * is attached.
- * @param input The byte array containing the content to be converted to
- * a PSInteger instance.
+ * Static method to attempt to create a PSInteger instance, if the input qualifies.
+ * All radix numbers are positive per PSRM2, Sec. 3.2.2, Subsection "Numbers".
+ * @param input The byte array containing the content to be converted to a PSInteger instance.
* @return A PSInteger instance, if the input qualifies, otherwise, null.
*/
- private static PsInteger parseRadixNumber(final PsInterpreter4a interpreter,
- final byte[] input) {
+ private static PsInteger parseRadixNumber(final byte[] input) {
// Every char must be a digit, a letter, or a # sign
for (int i = 0; i < input.length; i++) {
if (!isNumeral(input[i])
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 22:36:32 UTC (rev 13807)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 22:42:30 UTC (rev 13808)
@@ -687,10 +687,9 @@
return;
}
- PsObject object = null;
- object = PsInteger.create(this, this.tokenBeingBuilt.toArray());
+ PsObject object = PsInteger.create(this.tokenBeingBuilt.toArray());
if (object == null) {
- object = PsReal.create(this, this.tokenBeingBuilt.toArray());
+ object = PsReal.create(this.tokenBeingBuilt.toArray());
}
if (object == null) {
object = PsName.create(this.tokenBeingBuilt.toArray());
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsReal.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsReal.java 2025-06-02 22:36:32 UTC (rev 13807)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsReal.java 2025-06-02 22:42:30 UTC (rev 13808)
@@ -51,11 +51,10 @@
/**
* Static method to attempt to create a PSReal instance, if the input qualifies.
- * @param interpreter The parent interpreter.
* @param input The byte array containing the content to be converted to a PSReal instance.
* @return A PsReal instance, if the input qualifies, otherwise, null.
*/
- public static PsReal create(final PsInterpreter4a interpreter, final byte[] input) {
+ public static PsReal create(final byte[] input) {
// Every char must be a digit, sign, decimal point, E, or e
for (int i = 0; i < input.length; i++) {
if (!isNumeral(input[i])
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 22:36:32 UTC (rev 13807)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 22:42:30 UTC (rev 13808)
@@ -3636,7 +3636,7 @@
}
if (object instanceof PsString) {
final ByteArray value = ((PsString) object).getValue();
- final PsReal real = PsReal.create(this.getInterpreter(), value.toArray());
+ final PsReal real = PsReal.create(value.toArray());
this.pushOperand(real);
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-02 22:36:38
|
Revision: 13807
http://sourceforge.net/p/foray/code/13807
Author: victormote
Date: 2025-06-02 22:36:32 +0000 (Mon, 02 Jun 2025)
Log Message:
-----------
Improvements to creation of PsName.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 22:15:00 UTC (rev 13806)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 22:36:32 UTC (rev 13807)
@@ -158,16 +158,9 @@
/** The current graphics state. */
private PsGraphicsState currentGraphicsState = new PsGraphicsState();
- /**
- * Holds any partially-build token as it is being built.
- */
- private byte[] tokenBeingBuilt = new byte[PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ /** Holds any partially-build token as it is being built. */
+ private ByteArrayBuilder tokenBeingBuilt = new ByteArrayBuilder(PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES);
- /**
- * The portion of tokenBeingBuilt that is actually being used.
- */
- private short tokenBeingBuiltSize = 0;
-
/** Reusable buffer for building Strings. */
private ByteArrayBuilder stringBeingBuilt = new ByteArrayBuilder();
@@ -682,14 +675,7 @@
* @param inputByte The byte to be added.
*/
private void appendToToken(final byte inputByte) {
- /*
- * TODO: Should probably throw an exception here
- */
- if (this.tokenBeingBuiltSize > this.tokenBeingBuilt.length - 1) {
- return;
- }
- this.tokenBeingBuilt[this.tokenBeingBuiltSize] = inputByte;
- this.tokenBeingBuiltSize ++;
+ this.tokenBeingBuilt.append(inputByte);
}
/**
@@ -697,33 +683,22 @@
* @throws PsInterpreterException4a For any PostScript error.
*/
private void consumeToken() throws PsInterpreterException4a {
- if (this.tokenBeingBuiltSize < 1) {
+ if (this.tokenBeingBuilt.length() < 1) {
return;
}
- // Copy the token to a new byte array
- final byte[] token = new byte[this.tokenBeingBuiltSize];
- System.arraycopy(this.tokenBeingBuilt, 0, token, 0,
- this.tokenBeingBuiltSize);
- // Initialize tokenBeingBuilt and related items for next token
- this.tokenBeingBuiltSize = 0;
- // This is probably not really necessary, but seems cleaner.
- for (int i = 0; i < this.tokenBeingBuilt.length; i++) {
- this.tokenBeingBuilt[i] = 0x00;
- }
-// this.tokenCount ++;
+
PsObject object = null;
- object = PsInteger.create(this, token);
- if (object != null) {
- processToken(object);
- return;
+ object = PsInteger.create(this, this.tokenBeingBuilt.toArray());
+ if (object == null) {
+ object = PsReal.create(this, this.tokenBeingBuilt.toArray());
}
- object = PsReal.create(this, token);
- if (object != null) {
- processToken(object);
- return;
+ if (object == null) {
+ object = PsName.create(this.tokenBeingBuilt.toArray());
}
- object = PsName.create(this, token);
+
processToken(object);
+ /* Reset buffer for next token. */
+ this.tokenBeingBuilt.setLength(0);
}
/**
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-02 22:15:00 UTC (rev 13806)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-02 22:36:32 UTC (rev 13807)
@@ -62,14 +62,11 @@
}
/**
- * Static method to attempt to create a PsName instance, if the input
- * qualifies.
- * @param interpreter The parent interpreter.
- * @param input The byte array containing the content to be converted to
- * a PsName instance.
+ * Static method to attempt to create a PsName instance, if the input qualifies.
+ * @param input The byte array containing the content to be converted to a PsName instance.
* @return A PsName instance, if the input qualifies, otherwise, null.
*/
- public static PsName create(final PsInterpreter4a interpreter, final byte[] input) {
+ public static PsName create(final byte[] input) {
/*
* There is not really much validation work to do here that we know of.
* The input should be checked first to see whether it is a valid
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-02 22:15:07
|
Revision: 13806
http://sourceforge.net/p/foray/code/13806
Author: victormote
Date: 2025-06-02 22:15:00 +0000 (Mon, 02 Jun 2025)
Log Message:
-----------
Improvements to opening and closing streams, and hashcodes for name-related classes.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/sequence/ByteArray.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -107,6 +107,11 @@
this(charSequence.toString().getBytes(Charset.forName("US-ASCII")));
}
+ @Override
+ public int hashCode() {
+ return this.array.hashCode();
+ }
+
/**
* Converts an existing byte sequence to a byte array, creating the byte array only if necessary.
* @param sequence The sequence to be converted.
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -73,11 +73,8 @@
return false;
}
- /**
- * Close the input file.
- * @throws PsOperatorException For error popping the dictionary stack.
- */
- protected void closeFile() throws PsOperatorException, IOException {
+ @Override
+ public void close() throws IOException {
this.fis.close();
this.fileIsOpen = false;
}
@@ -103,13 +100,6 @@
return this.fileIsOpen;
}
- /**
- * Closes this file.
- */
- public void close() {
- this.fileIsOpen = false;
- }
-
@Override
public void setAccess(final PsAccess newAccess) {
if (allowChange(newAccess)) {
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -324,8 +324,9 @@
*/
private void processItem(final PsObject currentExecution)
throws PsOperatorException, PsInterpreterException4a {
- if (currentExecution instanceof PsFile) {
- executePSFile((PsFile) currentExecution);
+ if (currentExecution instanceof PsInputStream) {
+ final PsInputStream psInputStream = (PsInputStream) currentExecution;
+ executePsInputStream(psInputStream);
return;
}
if (currentExecution instanceof PsArrayExecuting
@@ -373,21 +374,21 @@
/**
* Execute a PostScript file.
- * @param file The file to execute.
+ * @param stream The file to execute.
* @throws PsOperatorException For errors executing operators.
* @throws PsInterpreterException4a For errors during execution.
*/
- private void executePSFile(final PsFile file) throws PsOperatorException, PsInterpreterException4a {
- if (! file.isOpen()) {
- this.executionStack.pop(PsOperator.INTERPRETER);
- return;
- }
+ private void executePsInputStream(final PsInputStream stream) throws PsOperatorException, PsInterpreterException4a {
+// if (! file.isOpen()) {
+// this.executionStack.pop(PsOperator.INTERPRETER);
+// return;
+// }
int intToConsume = 0;
try {
- intToConsume = file.read();
+ intToConsume = stream.read();
} catch (final IOException e) {
try {
- file.closeFile();
+ stream.close();
} catch (final IOException e1) {
/* Can't think of anything useful to do here. */
}
@@ -394,7 +395,14 @@
return;
}
if (intToConsume < 0) {
- file.close();
+ /* We are at the end of the stream. */
+ try {
+ stream.close();
+ } catch (final IOException e) {
+ /* Nothing useful to do here. */
+ }
+ /* Consume any in-process token. */
+ consumeToken();
this.executionStack.pop();
return;
}
@@ -754,16 +762,16 @@
}
// Otherwise, execute it.
PsDictionary currentDict = null;
- boolean doneExecuting = false;
- for (int i = 0; i < this.dictionaryStack.size() && !doneExecuting;
- i++) {
- currentDict = this.dictionaryStack.peek(i);
- doneExecuting = currentDict.execute(this, nameObject);
+ for (int index = 0; index < this.dictionaryStack.size(); index ++) {
+ currentDict = this.dictionaryStack.peek(index);
+ final PsObject value = currentDict.getMap().get(nameObject);
+ if (value != null) {
+ currentDict.execute(this, nameObject);
+ return;
+ }
}
- if (! doneExecuting) {
- throw new PsInterpreterException4a(this, PsError.UNDEFINED, PsOperator.INTERPRETER,
- "PostScript name '" + nameObject.getValue() + "' not found.");
- }
+ throw new PsInterpreterException4a(this, PsError.UNDEFINED, PsOperator.INTERPRETER,
+ "PostScript name '" + nameObject.getValue() + "' not found.");
}
/**
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsName.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -29,7 +29,8 @@
package org.foray.ps;
/**
- * Class representing a name PostScript object.
+ * Class representing a "name" PostScript object.
+ * @see "PostScript Language Reference, Section 3.3.8."
*/
public class PsName implements PsObjectSimple {
@@ -46,11 +47,9 @@
* Constructor.
* @param value The value to encapsulate.
* @param executable Set to true if this object is executable.
- * @param immediatelyEvaluated Set to true if this name should be evaluated
- * immediately.
+ * @param immediatelyEvaluated Set to true if this name should be evaluated immediately.
*/
- public PsName(final String value,
- final boolean executable, final boolean immediatelyEvaluated) {
+ public PsName(final String value, final boolean executable, final boolean immediatelyEvaluated) {
super();
this.value = value;
this.isExecutable = executable;
@@ -57,6 +56,11 @@
this.isImmediatelyEvaluated = immediatelyEvaluated;
}
+ @Override
+ public int hashCode() {
+ return this.value.hashCode();
+ }
+
/**
* Static method to attempt to create a PsName instance, if the input
* qualifies.
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -2099,7 +2099,11 @@
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.CLOSEFILE);
}
final PsFile file = (PsFile) object;
- file.close();
+ try {
+ file.close();
+ } catch (final IOException e) {
+ throw new PsOperatorException(PsError.IOERROR, PsOperator.CLOSEFILE);
+ }
}
/**
Modified: trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
===================================================================
--- trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-02 16:43:47 UTC (rev 13805)
+++ trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-02 22:15:00 UTC (rev 13806)
@@ -49,6 +49,7 @@
*/
private PsInputStream createPsInputFromString(final String inputString) {
final PsString psString = new PsString(new ByteArray(inputString));
+ psString.setExecutable(true);
return psString;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-02 16:43:50
|
Revision: 13805
http://sourceforge.net/p/foray/code/13805
Author: victormote
Date: 2025-06-02 16:43:47 +0000 (Mon, 02 Jun 2025)
Log Message:
-----------
Minor cleanup.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 16:34:48 UTC (rev 13804)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 16:43:47 UTC (rev 13805)
@@ -33,10 +33,7 @@
import java.io.IOException;
/**
- * Abstract superclass for PostScript "file" objects. A subclass instance
- * can be a wrapper around one of several things: 1) a real file, 2) an input
- * source, like standard input, or 3) a filter that sits on top of another
- * PsFile instance.
+ * A PostScript "file" object.
*/
public class PsFile extends PsInputStream implements PsObjectComposite {
@@ -49,19 +46,11 @@
/** Indicates whether the file is open. */
private boolean fileIsOpen = true;
- /** The current portion of the file that has been read and is available for
- * parsing. */
- private byte[] chunk = null;
-
- /** The index into {@link #chunk} indicating what has already been
- * parsed. */
- private int chunkIndex = -1;
-
/** The access permission for this object. */
private PsAccess access = PsAccess.UNLIMITED;
/**
- * Constructor for an instance that wraps a real file.
+ * Constructor.
* @param file The File to be encapsulated.
*/
public PsFile(final File file) {
@@ -88,30 +77,11 @@
* Close the input file.
* @throws PsOperatorException For error popping the dictionary stack.
*/
- protected void closeFile() throws PsOperatorException {
+ protected void closeFile() throws PsOperatorException, IOException {
+ this.fis.close();
this.fileIsOpen = false;
}
- /**
- * Return the last chunk for this file.
- * @return The last chunk for this file.
- */
- protected byte[] getRemainingChunk() {
- if (this.chunk == null) {
- return null;
- }
- final int arraySize = this.chunk.length - this.chunkIndex;
- if (arraySize < 1) {
- return null;
- }
- final byte[] remainingChunk = new byte[arraySize];
- System.arraycopy(this.chunk, this.chunkIndex, remainingChunk, 0,
- arraySize);
- // Advance the index past the boundary
- this.chunkIndex = this.chunk.length;
- return remainingChunk;
- }
-
@Override
public boolean isComparable(final PsObject object) {
if (object instanceof PsFile) {
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 16:34:48 UTC (rev 13804)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 16:43:47 UTC (rev 13805)
@@ -159,11 +159,9 @@
private PsGraphicsState currentGraphicsState = new PsGraphicsState();
/**
- * Holds any partially-build token as it is being built. This also serves
- * to maintain state between chunks.
+ * Holds any partially-build token as it is being built.
*/
- private byte[] tokenBeingBuilt =
- new byte[PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private byte[] tokenBeingBuilt = new byte[PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES];
/**
* The portion of tokenBeingBuilt that is actually being used.
@@ -170,9 +168,6 @@
*/
private short tokenBeingBuiltSize = 0;
-// /** Counter of the number of tokens processes, useful in debugging. */
-// private long tokenCount = 0;
-
/** Reusable buffer for building Strings. */
private ByteArrayBuilder stringBeingBuilt = new ByteArrayBuilder();
@@ -391,7 +386,11 @@
try {
intToConsume = file.read();
} catch (final IOException e) {
- file.closeFile();
+ try {
+ file.closeFile();
+ } catch (final IOException e1) {
+ /* Can't think of anything useful to do here. */
+ }
return;
}
if (intToConsume < 0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-06-02 16:34:53
|
Revision: 13804
http://sourceforge.net/p/foray/code/13804
Author: victormote
Date: 2025-06-02 16:34:48 +0000 (Mon, 02 Jun 2025)
Log Message:
-----------
Make PsInputStream implement PsObject.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputStream.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsFile.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -28,10 +28,6 @@
package org.foray.ps;
-import org.foray.primitive.sequence.ByteArray;
-
-import org.axsl.primitive.sequence.ByteSequence;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -50,9 +46,6 @@
/** The encapsulated input stream. */
private FileInputStream fis;
- /** The encapsulated input source for this object, if any. */
- private PsInputStream input;
-
/** Indicates whether the file is open. */
private boolean fileIsOpen = true;
@@ -76,16 +69,6 @@
this.value = file;
}
- /**
- * Constructor for an instance that wraps an input source (like standard
- * input).
- * @param input The input to be encapsulated.
- */
- public PsFile(final PsInputStream input) {
- super();
- this.input = input;
- }
-
@Override
public PsObject duplicate() {
return this;
@@ -102,49 +85,6 @@
}
/**
- * Returns the next byte from this file.
- * @return The next byte from this file.
- * @throws IOException For I/O Errors.
- * @throws PsOperatorException For PostScript error closing the file.
- */
- protected byte provideInput() throws IOException, PsOperatorException {
- if (this.chunk == null
- || this.chunk.length == 0
- || this.chunkIndex > this.chunk.length - 1) {
- this.chunk = getNextChunk();
- this.chunkIndex = 0;
- if (this.chunk == null
- || this.chunk.length == 0
- || this.chunkIndex > this.chunk.length - 1) {
- closeFile();
- return 0x00;
- }
- }
- this.chunkIndex ++;
- return this.chunk[this.chunkIndex - 1];
- }
-
- /**
- * Returns the next chunk of content for this file.
- * @return The next byte array for this file.
- * @throws IOException For I/O Errors.
- */
- protected byte[] getNextChunk() throws IOException {
- byte[] tempChunk = getRemainingChunk();
- if (tempChunk != null) {
- return tempChunk;
- }
- if (this.input != null) {
- final ByteSequence psInput = this.input.providePostScriptInput();
- tempChunk = psInput == null ? null : new ByteArray(psInput).toArray();
- } else if (this.value != null) {
- // TODO: Handle i/o from real files
- tempChunk = null;
- }
- return tempChunk;
- }
-
- /**
* Close the input file.
* @throws PsOperatorException For error popping the dictionary stack.
*/
@@ -228,10 +168,4 @@
return this.fis.read();
}
- @Override
- ByteSequence providePostScriptInput() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsGenericInputStream.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -28,8 +28,6 @@
package org.foray.ps;
-import org.axsl.primitive.sequence.ByteSequence;
-
import java.io.IOException;
import java.io.InputStream;
@@ -76,11 +74,6 @@
}
@Override
- ByteSequence providePostScriptInput() throws IOException {
- return null;
- }
-
- @Override
public int read() throws IOException {
return this.inputStream.read();
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputStream.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputStream.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -28,28 +28,11 @@
package org.foray.ps;
-import org.axsl.primitive.sequence.ByteSequence;
-
-import java.io.IOException;
import java.io.InputStream;
/**
- * Interface for objects that wish to be used as input to the PostScript interpreter.
- * This interface is needed because a variety of file types may be used as input to a PostScript interpreter.
- * For example, Type 1 font files are frequently packaged in operating-system-specific wrapper files that must be
- * unwrapped (and sometimes decoded) before they can be consumed by the PostScript interpreter.
- * This interface allows other classes to do that work and pass the results through to the interpreter.
- *
- * Please note that the implementing class is responsible for any buffering of
- * the data for i/o efficiency purposes.
+ * Interface for objects used as input to the PostScript interpreter.
*/
-public abstract class PsInputStream extends InputStream {
+public abstract class PsInputStream extends InputStream implements PsObject {
- /**
- * Returns the next byte array chunk in the input so that it can be consumed by the PostScript interpreter.
- * @return The next byte array that should be consumed by the interpreter, or null if there is no more input.
- * @throws IOException For I/O Errors.
- */
- abstract ByteSequence providePostScriptInput() throws IOException;
-
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -208,7 +208,7 @@
private boolean inProcedure = false;
/** The PsFile representing "STDIN", the standard input. */
- private PsFile standardInput;
+ private PsInputStream standardInput;
/** Tracks the current line number being parsed. */
private int currentLine = 1;
@@ -237,7 +237,7 @@
throw new NullPointerException("PostScript Error: No standard input.");
}
// Create the standard input file.
- this.standardInput = new PsFile(input);
+ this.standardInput = (input);
// Place it on the execution stack.
this.executionStack.push(this.standardInput);
// Get the System Dictionary.
@@ -387,13 +387,19 @@
this.executionStack.pop(PsOperator.INTERPRETER);
return;
}
- byte byteToConsume = 0;
+ int intToConsume = 0;
try {
- byteToConsume = file.provideInput();
+ intToConsume = file.read();
} catch (final IOException e) {
file.closeFile();
return;
}
+ if (intToConsume < 0) {
+ file.close();
+ this.executionStack.pop();
+ return;
+ }
+ final byte byteToConsume = (byte) intToConsume;
adjustCounters(byteToConsume);
autoDelimitByte(byteToConsume);
consumeByte(byteToConsume);
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsString.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -30,8 +30,6 @@
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.primitive.sequence.ByteSequence;
-
import java.io.IOException;
/**
@@ -184,9 +182,4 @@
return this.value.byteAt(nextIndex - 1);
}
- @Override
- ByteSequence providePostScriptInput() throws IOException {
- return null;
- }
-
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsSystemDict4a.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -1896,7 +1896,7 @@
int charsRead = 0;
for (int i = 0; i < string.getValue().length() && file.isOpen(); i++) {
try {
- builder.setByteAt(i, (byte) file.provideInput());
+ builder.setByteAt(i, (byte) file.read());
} catch (final IOException e) {
throw new PsOperatorException(e, PsError.IOERROR, PsOperator.READSTRING, null);
}
Modified: trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java
===================================================================
--- trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-02 16:22:57 UTC (rev 13803)
+++ trunk/foray/foray-ps/src/test/java/org/foray/ps/PsSystemDict4aTests.java 2025-06-02 16:34:48 UTC (rev 13804)
@@ -1700,7 +1700,7 @@
PsObject object1 = interpreter.getOperandStack().peek();
assertTrue(object1 instanceof PsReal);
input = createPsInputFromString("cvr");
- interpreter.getExecutionStack().push(new PsFile(input));
+ interpreter.getExecutionStack().push(input);
interpreter.process();
PsObject object2 = interpreter.getOperandStack().pop();
assertTrue(object2 instanceof PsReal);
@@ -1714,7 +1714,7 @@
object1 = interpreter.getOperandStack().peek();
assertTrue(object1 instanceof PsInteger);
input = createPsInputFromString("cvr");
- interpreter.getExecutionStack().push(new PsFile(input));
+ interpreter.getExecutionStack().push(input);
interpreter.process();
object2 = interpreter.getOperandStack().pop();
assertTrue(object2 instanceof PsReal);
@@ -1730,7 +1730,7 @@
object1 = interpreter.getOperandStack().peek();
assertTrue(object1 instanceof PsString);
input = createPsInputFromString("cvr");
- interpreter.getExecutionStack().push(new PsFile(input));
+ interpreter.getExecutionStack().push(input);
interpreter.process();
object2 = interpreter.getOperandStack().pop();
assertTrue(object2 instanceof PsReal);
@@ -1744,7 +1744,7 @@
object1 = interpreter.getOperandStack().peek();
assertTrue(object1 instanceof PsString);
input = createPsInputFromString("cvr");
- interpreter.getExecutionStack().push(new PsFile(input));
+ interpreter.getExecutionStack().push(input);
interpreter.process();
object2 = interpreter.getOperandStack().pop();
assertTrue(object2 instanceof PsReal);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|