Skip to content

Commit

Permalink
Standardise String/Constant conversion CodeGen enhancements
Browse files Browse the repository at this point in the history
Standardised JRecord-Constant - String Conversion also add support the Conversion of JRecord-Constants to/from JRecord-constant as a String for use in Code generation (CodeGen).

Adding support for Generating Message processing exaples in Code gen

Improved support for  String lines in CodeGen generated code
  • Loading branch information
bmTas committed Apr 25, 2024
1 parent e6f75db commit 9ab8cf4
Show file tree
Hide file tree
Showing 43 changed files with 3,834 additions and 2,075 deletions.
2 changes: 1 addition & 1 deletion Source/JRecord_Project/JRecord/src/main/java/net/sf/JRecord/Details/CharLine.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void setData(byte[] newVal) {

@Override
public void setData(String newVal) {
data = newVal;
data =newVal == null ? "" : newVal;
clearOdBuffers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import net.sf.JRecord.Common.Constants;
import net.sf.JRecord.Common.Conversion;
import net.sf.JRecord.Common.FieldDetail;
import net.sf.JRecord.Common.IFileStructureConstants;
import net.sf.JRecord.Common.RecordException;
import net.sf.JRecord.Details.LayoutDetail;
import net.sf.JRecord.Details.LayoutGetFieldByName;
Expand Down Expand Up @@ -754,17 +755,32 @@ public final net.sf.JRecord.def.IO.builders.ISchemaIOBuilder asIOBuilder() {




public static IFixedWidthSchemaBuilder newFixedWidthRecord(String name, int fileStructure, String fontName) {
ExternalRecord r = getNullRecord(name, Constants.rtRecordLayout, fontName);
/**
* Create a fixed width schema
* @param schemaName Schema-Name of the schema being created
* @param fileStructure file structure constant i.e IFileStructureConstants.IO_STANDARD_TEXT_FILE
* or IFileStructureConstants.IO_FIXED_LENGTH_RECORDS
* @param fontName font or encoding name
* @return Fixed-Width Schema-Builder
*/
public static IFixedWidthSchemaBuilder newFixedWidthRecord(String schemaName, int fileStructure, String fontName) {
ExternalRecord r = getNullRecord(schemaName, Constants.rtRecordLayout, fontName);
r.setFileStructure(fileStructure);

return r;
}


public static ICsvSchemaBuilder newCsvRecord(String name, int fileStructure, String fontName, String delimeter, String quote) {
ExternalRecord r = new ExternalRecord(-1, name, "", Constants.rtDelimited, 0, "N",
/**
* Create Csv Schema
* @param schemaName Name of the Csv-Schema
* @param fileStructure FileStructure of the file normally IFileStructureConstants.IO_STANDARD_TEXT_FILE
* @param fontName font or encoding name
* @param delimeter field delimiter or field separator (e.g. ",")
* @param quote quote character (e.g. "\"" or "'")
* @return CsvSchemaBuilder
*/
public static ICsvSchemaBuilder newCsvRecord(String schemaName, int fileStructure, String fontName, String delimeter, String quote) {
ExternalRecord r = new ExternalRecord(-1, schemaName, "", Constants.rtDelimited, 0, "N",
"", delimeter, quote, 0, Constants.DEFAULT_STRING, Constants.SYSTEM_EOL_BYTES, fontName, 0, fileStructure, false);

return r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ private ExternalRecord loadCopybook(XmlLineReader reader, String copyBookName, S
throws IOException {
return (new BaseRecordEditorXmlLoader<ExternalRecord>(
new XmlReader(reader),
new ExternalRecordBuilder()
new ExternalRecordBuilder(),
null
)).loadCopyBook(copyBookName, font, log);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/JRecord_Project/JRecord/src/main/java/net/sf/JRecord/IO/LineIOProvider.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public class LineIOProvider implements AbstractManager {
};
}

@Deprecated
@Deprecated
public static final String[] FILE_STRUCTURE = {
"Default Reader",
"Fixed Length Binary",
Expand Down
70 changes: 35 additions & 35 deletions Source/JRecord_Project/JRecord/src/main/java/net/sf/JRecord/IO/ListLineWriter.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package net.sf.JRecord.IO;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

import net.sf.JRecord.Details.AbstractLine;


/**
* Write `Lines` to a list
* @author Bruce Martin
*
*/
public class ListLineWriter extends AbstractLineWriter {

private final ArrayList<AbstractLine> lines = new ArrayList<AbstractLine>();
@Override
public void open(OutputStream outputStream) throws IOException {
lines.clear();
}

@Override
public void write(AbstractLine line) throws IOException {
lines.add(line);
}

@Override
public void close() throws IOException { }

public ArrayList<AbstractLine> getLines() {
return lines;
}

}
package net.sf.JRecord.IO;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

import net.sf.JRecord.Details.AbstractLine;


/**
* Write `Lines` to a list
* @author Bruce Martin
*
*/
public class ListLineWriter extends AbstractLineWriter {

private final ArrayList<AbstractLine> lines = new ArrayList<AbstractLine>();
@Override
public void open(OutputStream outputStream) throws IOException {
lines.clear();
}

@Override
public void write(AbstractLine line) throws IOException {
lines.add(line);
}

@Override
public void close() throws IOException { }

public ArrayList<AbstractLine> getLines() {
return lines;
}

}
88 changes: 44 additions & 44 deletions Source/JRecord_Project/JRecord/src/main/java/net/sf/JRecord/IO/SingleLineReader.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
package net.sf.JRecord.IO;

import java.io.IOException;
import java.io.InputStream;

import net.sf.JRecord.Details.AbstractLine;
import net.sf.JRecord.Details.LayoutDetail;

/**
* C
* @author Bruce Martin
*
*/
public class SingleLineReader extends AbstractLineReader {

private AbstractLine line;

public SingleLineReader(AbstractLine line) {
setLine(line);
}

public void setLine(AbstractLine line) {
this.line = line;
super.setLayout(line.getLayout());
}

@Override
public void open(InputStream inputStream, LayoutDetail pLayout) throws IOException {

}

@Override
public AbstractLine readImplementation() throws IOException {
AbstractLine ret = line;
line = null;
return ret;
}

@Override
public void close() throws IOException {
line = null;
}

}
package net.sf.JRecord.IO;

import java.io.IOException;
import java.io.InputStream;

import net.sf.JRecord.Details.AbstractLine;
import net.sf.JRecord.Details.LayoutDetail;

/**
* C
* @author Bruce Martin
*
*/
public class SingleLineReader extends AbstractLineReader {

private AbstractLine line;

public SingleLineReader(AbstractLine line) {
setLine(line);
}

public void setLine(AbstractLine line) {
this.line = line;
super.setLayout(line.getLayout());
}

@Override
public void open(InputStream inputStream, LayoutDetail pLayout) throws IOException {

}

@Override
public AbstractLine readImplementation() throws IOException {
AbstractLine ret = line;
line = null;
return ret;
}

@Override
public void close() throws IOException {
line = null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,8 @@ private void doCheck() {
}

/**
* Not used
* @return
* @deprecated not used in JRecord will be removed
*
*/
@Deprecated
public ExternalRecord createExternalRecord() throws Exception {

ICopybookLoaderStream loader = parent.getLoader();
Expand Down
130 changes: 65 additions & 65 deletions ...ct/JRecord/src/main/java/net/sf/JRecord/IO/builders/CreateExternalFromCb2xmlCopybook.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
/* -------------------------------------------------------------------------
*
* Project: JRecord
*
* Sub-Project purpose: Provide support for reading Cobol-Data files
* using a Cobol Copybook in Java.
* Support for reading Fixed Width / Binary / Csv files
* using a Xml schema.
* General Fixed Width / Csv file processing in Java.
*
* Author: Bruce Martin
*
* License: LGPL 2.1 or latter
*
* Copyright (c) 2016, Bruce Martin, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* ------------------------------------------------------------------------ */

package net.sf.JRecord.IO.builders;

import net.sf.JRecord.Common.Conversion;
import net.sf.JRecord.Common.RecordException;
import net.sf.JRecord.External.CobolCopybookLoader;
import net.sf.JRecord.External.ExternalRecord;
import net.sf.JRecord.External.ICopybookLoaderStream;
import net.sf.cb2xml.def.ICopybookJrUpd;

public class CreateExternalFromCb2xmlCopybook extends CreateExternalBase implements ICreateExternal {

private final ICopybookJrUpd copybook;
// private final CblIOBuilderMultiSchema parent;



public CreateExternalFromCb2xmlCopybook(IGetLoader parent, ICopybookJrUpd copybook) {
super(parent, Conversion.getCopyBookId(copybook.getFilename()));
this.copybook = copybook;
}


@Override
protected ExternalRecord createExternalRecordImp() throws Exception {
ICopybookLoaderStream loader = parent.getLoader();

if (! (loader instanceof CobolCopybookLoader)) {
throw new RecordException(ONLY_USED_WITH_COBOL);
}

return ((CobolCopybookLoader) loader).loadCopybook(
copybook,
Conversion.getCopyBookId(copybook.getFilename()),
splitCopybook, 0,
parent.getFont(), parent.getDialect(), 0);
}
}
/* -------------------------------------------------------------------------
*
* Project: JRecord
*
* Sub-Project purpose: Provide support for reading Cobol-Data files
* using a Cobol Copybook in Java.
* Support for reading Fixed Width / Binary / Csv files
* using a Xml schema.
* General Fixed Width / Csv file processing in Java.
*
* Author: Bruce Martin
*
* License: LGPL 2.1 or latter
*
* Copyright (c) 2016, Bruce Martin, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* ------------------------------------------------------------------------ */

package net.sf.JRecord.IO.builders;

import net.sf.JRecord.Common.Conversion;
import net.sf.JRecord.Common.RecordException;
import net.sf.JRecord.External.CobolCopybookLoader;
import net.sf.JRecord.External.ExternalRecord;
import net.sf.JRecord.External.ICopybookLoaderStream;
import net.sf.cb2xml.def.ICopybookJrUpd;

public class CreateExternalFromCb2xmlCopybook extends CreateExternalBase implements ICreateExternal {

private final ICopybookJrUpd copybook;
// private final CblIOBuilderMultiSchema parent;



public CreateExternalFromCb2xmlCopybook(IGetLoader parent, ICopybookJrUpd copybook) {
super(parent, Conversion.getCopyBookId(copybook.getFilename()));
this.copybook = copybook;
}


@Override
protected ExternalRecord createExternalRecordImp() throws Exception {
ICopybookLoaderStream loader = parent.getLoader();

if (! (loader instanceof CobolCopybookLoader)) {
throw new RecordException(ONLY_USED_WITH_COBOL);
}

return ((CobolCopybookLoader) loader).loadCopybook(
copybook,
Conversion.getCopyBookId(copybook.getFilename()),
splitCopybook, 0,
parent.getFont(), parent.getDialect(), 0);
}
}
Loading

0 comments on commit 9ab8cf4

Please sign in to comment.