Commit df53aaf5 authored by claes's avatar claes

More c-printf compatible output format implemented

parent 9975b12c
/* /*
* Proview $Id: GeCFormat.java,v 1.5 2005-09-12 10:48:00 claes Exp $ * Proview $Id: GeCFormat.java,v 1.6 2007-05-24 12:26:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -26,6 +26,7 @@ public class GeCFormat { ...@@ -26,6 +26,7 @@ public class GeCFormat {
int f_idx, p_idx; int f_idx, p_idx;
try { try {
/*
if ( (f_idx = format.indexOf('f')) != -1) { if ( (f_idx = format.indexOf('f')) != -1) {
format_type = FRM_F; format_type = FRM_F;
p_idx = format.indexOf('.'); p_idx = format.indexOf('.');
...@@ -68,7 +69,8 @@ public class GeCFormat { ...@@ -68,7 +69,8 @@ public class GeCFormat {
h = Integer.valueOf(format.substring( 1+no_space, p_idx)).intValue(); h = Integer.valueOf(format.substring( 1+no_space, p_idx)).intValue();
} }
} }
else if ( (f_idx = format.indexOf('o')) != -1) { */
if ( (f_idx = format.indexOf('o')) != -1) {
if ( f_idx >= 1 && format.charAt(f_idx-1) == '1') if ( f_idx >= 1 && format.charAt(f_idx-1) == '1')
format_type = FRM_1O; format_type = FRM_1O;
else if ( f_idx >= 1 && format.charAt(f_idx-1) == '2') else if ( f_idx >= 1 && format.charAt(f_idx-1) == '2')
...@@ -92,6 +94,8 @@ public class GeCFormat { ...@@ -92,6 +94,8 @@ public class GeCFormat {
else else
format_type = FRM_M; format_type = FRM_M;
} }
else
pfo = new PrintfFormat( format);
} }
catch ( NumberFormatException e) { catch ( NumberFormatException e) {
System.out.println( "NumberFormatException: " + format); System.out.println( "NumberFormatException: " + format);
...@@ -102,6 +106,7 @@ public class GeCFormat { ...@@ -102,6 +106,7 @@ public class GeCFormat {
int h; int h;
int no_space = 0; int no_space = 0;
int format_type; int format_type;
PrintfFormat pfo;
public static final int FRM_S = 0; // String public static final int FRM_S = 0; // String
public static final int FRM_O = 1; // Objid object name public static final int FRM_O = 1; // Objid object name
...@@ -121,6 +126,11 @@ public class GeCFormat { ...@@ -121,6 +126,11 @@ public class GeCFormat {
return format_type; return format_type;
} }
public StringBuffer format( float value, StringBuffer buff) { public StringBuffer format( float value, StringBuffer buff) {
if ( pfo != null)
return pfo.sprintf( value, buff);
else
return buff;
/*
int j, len; int j, len;
int t2 = (int) value; int t2 = (int) value;
int m; int m;
...@@ -156,8 +166,14 @@ public class GeCFormat { ...@@ -156,8 +166,14 @@ public class GeCFormat {
} }
return buff; return buff;
} }
}
public StringBuffer format( int value, StringBuffer buff) { public StringBuffer format( int value, StringBuffer buff) {
if ( pfo != null)
return pfo.sprintf( value, buff);
else
return buff;
/*
int j, len; int j, len;
int t2 = value; int t2 = value;
...@@ -170,6 +186,7 @@ public class GeCFormat { ...@@ -170,6 +186,7 @@ public class GeCFormat {
for ( j = 0; j < h-len; j++) for ( j = 0; j < h-len; j++)
buff.insert(0," "); buff.insert(0," ");
return buff; return buff;
*/
} }
public StringBuffer format( boolean value, StringBuffer buff) { public StringBuffer format( boolean value, StringBuffer buff) {
...@@ -184,6 +201,11 @@ public class GeCFormat { ...@@ -184,6 +201,11 @@ public class GeCFormat {
public StringBuffer format( String value, StringBuffer buff) { public StringBuffer format( String value, StringBuffer buff) {
switch( format_type) { switch( format_type) {
case FRM_S: { case FRM_S: {
if ( pfo != null)
return pfo.sprintf( value, buff);
else
return buff;
/*
int j, len; int j, len;
if ( h == -1) if ( h == -1)
...@@ -196,6 +218,7 @@ public class GeCFormat { ...@@ -196,6 +218,7 @@ public class GeCFormat {
for ( j = 0; j < len; j++) for ( j = 0; j < len; j++)
buff.append(value.charAt(j)); buff.append(value.charAt(j));
return buff; return buff;
*/
} }
case FRM_O: { case FRM_O: {
int idx, j, len; int idx, j, len;
......
This diff is collapsed.
...@@ -3,6 +3,7 @@ include $(pwre_dir_symbols) ...@@ -3,6 +3,7 @@ include $(pwre_dir_symbols)
local_java_sources := \ local_java_sources := \
JopLog.java \ JopLog.java \
Ge.java \ Ge.java \
PrintfFormat.java \
GeCFormat.java \ GeCFormat.java \
GeDyndata.java \ GeDyndata.java \
GeColor.java \ GeColor.java \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment