remove class Vargs
This commit is contained in:
@@ -23,7 +23,6 @@ import lwjake2.Globals;
|
|||||||
import lwjake2.qcommon.Com;
|
import lwjake2.qcommon.Com;
|
||||||
import lwjake2.qcommon.MSG;
|
import lwjake2.qcommon.MSG;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CL_inv
|
* CL_inv
|
||||||
@@ -120,8 +119,8 @@ public class CL_inv {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string = Com.sprintf("%6s %3i %s", new Vargs(3).add(bind).add(Globals.cl.inventory[item]).add(
|
string = Com.sprintf("%6s %3i %s",
|
||||||
Globals.cl.configstrings[Defines.CS_ITEMS + item]));
|
bind, Globals.cl.inventory[item], Globals.cl.configstrings[Defines.CS_ITEMS + item]);
|
||||||
if (item != selected)
|
if (item != selected)
|
||||||
string = getHighBitString(string);
|
string = getHighBitString(string);
|
||||||
else // draw a blinky cursor by the selected item
|
else // draw a blinky cursor by the selected item
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import lwjake2.Globals;
|
|||||||
import lwjake2.game.Cmd;
|
import lwjake2.game.Cmd;
|
||||||
import lwjake2.qcommon.*;
|
import lwjake2.qcommon.*;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@@ -511,7 +510,7 @@ public final class Console {
|
|||||||
SCR.AddDirtyPoint(0, 0);
|
SCR.AddDirtyPoint(0, 0);
|
||||||
SCR.AddDirtyPoint(viddef.width - 1, lines - 1);
|
SCR.AddDirtyPoint(viddef.width - 1, lines - 1);
|
||||||
|
|
||||||
version = Com.sprintf("v%4.2f", new Vargs(1).add(VERSION));
|
version = Com.sprintf("v%4.2f", VERSION);
|
||||||
for (x = 0; x < 5; x++)
|
for (x = 0; x < 5; x++)
|
||||||
re.DrawChar(viddef.width - 44 + x * 8, lines - 12, 128 + version
|
re.DrawChar(viddef.width - 44 + x * 8, lines - 12, 128 + version
|
||||||
.charAt(x));
|
.charAt(x));
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import lwjake2.qcommon.*;
|
|||||||
import lwjake2.sound.S;
|
import lwjake2.sound.S;
|
||||||
import lwjake2.sys.Timer;
|
import lwjake2.sys.Timer;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@@ -985,8 +984,7 @@ public final class SCR {
|
|||||||
ping = 999;
|
ping = 999;
|
||||||
|
|
||||||
// sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
|
// sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
|
||||||
String block = Com.sprintf("%3d %3d %-12.12s", new Vargs(3)
|
String block = Com.sprintf("%3d %3d %-12.12s", score, ping, ci.name);
|
||||||
.add(score).add(ping).add(ci.name));
|
|
||||||
|
|
||||||
if (value == cl.playernum)
|
if (value == cl.playernum)
|
||||||
Console.DrawAltString(x, y, block);
|
Console.DrawAltString(x, y, block);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import lwjake2.qcommon.Cvar;
|
|||||||
import lwjake2.render.Renderer;
|
import lwjake2.render.Renderer;
|
||||||
import lwjake2.sound.S;
|
import lwjake2.sound.S;
|
||||||
import lwjake2.sys.IN;
|
import lwjake2.sys.IN;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import lwjake2.Defines;
|
|||||||
import lwjake2.qcommon.Com;
|
import lwjake2.qcommon.Com;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.Math3D;
|
import lwjake2.util.Math3D;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
public class PlayerHud {
|
public class PlayerHud {
|
||||||
|
|
||||||
@@ -516,13 +515,14 @@ public class PlayerHud {
|
|||||||
.append("\" "); // help 2
|
.append("\" "); // help 2
|
||||||
sb.append("xv 50 yv 164 string2 \" kills goals secrets\" ");
|
sb.append("xv 50 yv 164 string2 \" kills goals secrets\" ");
|
||||||
sb.append("xv 50 yv 172 string2 \"");
|
sb.append("xv 50 yv 172 string2 \"");
|
||||||
sb.append(Com.sprintf("%3i/%3i %i/%i %i/%i\" ", new Vargs(6)
|
sb.append(Com.sprintf("%3i/%3i %i/%i %i/%i\" ",
|
||||||
.add(GameBase.level.killed_monsters).add(
|
GameBase.level.killed_monsters,
|
||||||
GameBase.level.total_monsters).add(
|
GameBase.level.total_monsters,
|
||||||
GameBase.level.found_goals).add(
|
GameBase.level.found_goals,
|
||||||
GameBase.level.total_goals).add(
|
GameBase.level.total_goals,
|
||||||
GameBase.level.found_secrets).add(
|
GameBase.level.found_secrets,
|
||||||
GameBase.level.total_secrets)));
|
GameBase.level.total_secrets
|
||||||
|
));
|
||||||
|
|
||||||
GameBase.gi.WriteByte(Defines.svc_layout);
|
GameBase.gi.WriteByte(Defines.svc_layout);
|
||||||
GameBase.gi.WriteString(sb.toString());
|
GameBase.gi.WriteString(sb.toString());
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import lwjake2.game.Cmd;
|
|||||||
import lwjake2.server.SV_MAIN;
|
import lwjake2.server.SV_MAIN;
|
||||||
import lwjake2.sys.Sys;
|
import lwjake2.sys.Sys;
|
||||||
import lwjake2.util.PrintfFormat;
|
import lwjake2.util.PrintfFormat;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -241,12 +240,7 @@ public final class Com {
|
|||||||
|
|
||||||
public static Runnable Error_f= () -> Error(ErrorCode.ERR_FATAL, Cmd.Argv(1));
|
public static Runnable Error_f= () -> Error(ErrorCode.ERR_FATAL, Cmd.Argv(1));
|
||||||
|
|
||||||
public static void Error(int code, String fmt) throws IllegalStateException
|
public static void Error(int code, String fmt, Object... vargs) throws IllegalStateException
|
||||||
{
|
|
||||||
Error(code, fmt, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Error(int code, String fmt, Vargs vargs) throws IllegalStateException
|
|
||||||
{
|
{
|
||||||
// va_list argptr;
|
// va_list argptr;
|
||||||
// static char msg[MAXPRINTMSG];
|
// static char msg[MAXPRINTMSG];
|
||||||
@@ -257,7 +251,7 @@ public final class Com {
|
|||||||
}
|
}
|
||||||
recursive= true;
|
recursive= true;
|
||||||
|
|
||||||
msg= sprintf(fmt, vargs);
|
msg = sprintf(fmt, vargs);
|
||||||
|
|
||||||
if (code == ErrorCode.ERR_DISCONNECT)
|
if (code == ErrorCode.ERR_DISCONNECT)
|
||||||
{
|
{
|
||||||
@@ -304,16 +298,13 @@ public final class Com {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sprintf(String fmt, Vargs vargs)
|
public static String sprintf(String fmt, Object... vargs)
|
||||||
{
|
{
|
||||||
String msg= "";
|
String msg = "";
|
||||||
if (vargs == null || vargs.size() == 0)
|
if (vargs == null || vargs.length == 0) {
|
||||||
{
|
msg = fmt;
|
||||||
msg= fmt;
|
} else {
|
||||||
}
|
msg = new PrintfFormat(fmt).sprintf(vargs);
|
||||||
else
|
|
||||||
{
|
|
||||||
msg= new PrintfFormat(fmt).sprintf(vargs.toArray());
|
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import lwjake2.server.SV_MAIN;
|
|||||||
import lwjake2.sys.NET;
|
import lwjake2.sys.NET;
|
||||||
import lwjake2.sys.Sys;
|
import lwjake2.sys.Sys;
|
||||||
import lwjake2.sys.Timer;
|
import lwjake2.sys.Timer;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -103,11 +102,10 @@ public final class Qcommon {
|
|||||||
Globals.showtrace= Cvar.Get("showtrace", "0", 0);
|
Globals.showtrace= Cvar.Get("showtrace", "0", 0);
|
||||||
Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET);
|
Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET);
|
||||||
String s = Com.sprintf("%4.2f %s %s %s",
|
String s = Com.sprintf("%4.2f %s %s %s",
|
||||||
new Vargs(4)
|
Globals.VERSION,
|
||||||
.add(Globals.VERSION)
|
CPUSTRING,
|
||||||
.add(CPUSTRING)
|
Globals.__DATE__,
|
||||||
.add(Globals.__DATE__)
|
BUILDSTRING);
|
||||||
.add(BUILDSTRING));
|
|
||||||
|
|
||||||
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
|
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import lwjake2.Defines;
|
import lwjake2.Defines;
|
||||||
import lwjake2.ErrorCode;
|
import lwjake2.ErrorCode;
|
||||||
import dmx.lwjake2.UnpackLoader;
|
import dmx.lwjake2.UnpackLoader;
|
||||||
import lwjake2.client.VID;
|
|
||||||
import lwjake2.client.particle_t;
|
import lwjake2.client.particle_t;
|
||||||
import lwjake2.game.cvar_t;
|
import lwjake2.game.cvar_t;
|
||||||
import lwjake2.qcommon.*;
|
import lwjake2.qcommon.*;
|
||||||
import dmx.lwjake2.render.Q2Image;
|
import dmx.lwjake2.render.Q2Image;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import dmx.lwjake2.render.Q2Image;
|
|||||||
import lwjake2.render.mleaf_t;
|
import lwjake2.render.mleaf_t;
|
||||||
import lwjake2.render.model_t;
|
import lwjake2.render.model_t;
|
||||||
import lwjake2.util.Math3D;
|
import lwjake2.util.Math3D;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import dmx.lwjake2.render.ModelType;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lwjake2.Defines;
|
import lwjake2.Defines;
|
||||||
import lwjake2.ErrorCode;
|
import lwjake2.ErrorCode;
|
||||||
import lwjake2.client.VID;
|
|
||||||
import lwjake2.game.cplane_t;
|
import lwjake2.game.cplane_t;
|
||||||
import lwjake2.game.cvar_t;
|
import lwjake2.game.cvar_t;
|
||||||
import lwjake2.qcommon.Com;
|
import lwjake2.qcommon.Com;
|
||||||
@@ -40,7 +39,6 @@ import lwjake2.render.msurface_t;
|
|||||||
import lwjake2.render.mtexinfo_t;
|
import lwjake2.render.mtexinfo_t;
|
||||||
import lwjake2.render.mvertex_t;
|
import lwjake2.render.mvertex_t;
|
||||||
import lwjake2.util.Math3D;
|
import lwjake2.util.Math3D;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -1036,7 +1034,7 @@ public abstract class Model extends Surf {
|
|||||||
|
|
||||||
if (pheader.version != qfiles.ALIAS_VERSION)
|
if (pheader.version != qfiles.ALIAS_VERSION)
|
||||||
Com.Error(ErrorCode.ERR_DROP, "%s has wrong version number (%i should be %i)",
|
Com.Error(ErrorCode.ERR_DROP, "%s has wrong version number (%i should be %i)",
|
||||||
new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION));
|
mod.name, pheader.version, qfiles.ALIAS_VERSION);
|
||||||
|
|
||||||
if (pheader.skinheight > MAX_LBM_HEIGHT)
|
if (pheader.skinheight > MAX_LBM_HEIGHT)
|
||||||
Com.Error(ErrorCode.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT);
|
Com.Error(ErrorCode.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT);
|
||||||
@@ -1154,11 +1152,11 @@ public abstract class Model extends Surf {
|
|||||||
|
|
||||||
if (sprout.version != qfiles.SPRITE_VERSION)
|
if (sprout.version != qfiles.SPRITE_VERSION)
|
||||||
Com.Error(ErrorCode.ERR_DROP, "%s has wrong version number (%i should be %i)",
|
Com.Error(ErrorCode.ERR_DROP, "%s has wrong version number (%i should be %i)",
|
||||||
new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION));
|
mod.name, sprout.version, qfiles.SPRITE_VERSION);
|
||||||
|
|
||||||
if (sprout.numframes > qfiles.MAX_MD2SKINS)
|
if (sprout.numframes > qfiles.MAX_MD2SKINS)
|
||||||
Com.Error(ErrorCode.ERR_DROP, "%s has too many frames (%i > %i)",
|
Com.Error(ErrorCode.ERR_DROP, "%s has too many frames (%i > %i)",
|
||||||
new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS));
|
mod.name, sprout.numframes, qfiles.MAX_MD2SKINS);
|
||||||
|
|
||||||
for (int i=0 ; i<sprout.numframes ; i++)
|
for (int i=0 ; i<sprout.numframes ; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import lwjake2.sys.NET;
|
|||||||
import lwjake2.sys.Sys;
|
import lwjake2.sys.Sys;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
import lwjake2.util.QuakeFile;
|
import lwjake2.util.QuakeFile;
|
||||||
import lwjake2.util.Vargs;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -395,12 +394,11 @@ public class SV_CCMDS {
|
|||||||
|
|
||||||
if (!autosave) {
|
if (!autosave) {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
comment =
|
comment = Com.sprintf("%2i:%2i %2i/%2i ",
|
||||||
Com.sprintf(
|
c.get(Calendar.HOUR_OF_DAY),
|
||||||
"%2i:%2i %2i/%2i ",
|
c.get(Calendar.MINUTE),
|
||||||
new Vargs().add(c.get(Calendar.HOUR_OF_DAY)).add(c.get(Calendar.MINUTE)).add(
|
c.get(Calendar.MONTH) + 1,
|
||||||
c.get(Calendar.MONTH) + 1).add(
|
c.get(Calendar.DAY_OF_MONTH));
|
||||||
c.get(Calendar.DAY_OF_MONTH)));
|
|
||||||
comment += SV_INIT.sv.configstrings[Defines.CS_NAME];
|
comment += SV_INIT.sv.configstrings[Defines.CS_NAME];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class Lib {
|
|||||||
|
|
||||||
/** Converts a vector to a beatiful string. */
|
/** Converts a vector to a beatiful string. */
|
||||||
public static String vtofsbeaty(float[] v) {
|
public static String vtofsbeaty(float[] v) {
|
||||||
return Com.sprintf("%8.2f %8.2f %8.2f", new Vargs().add(v[0]).add(v[1]).add(v[2]));
|
return Com.sprintf("%8.2f %8.2f %8.2f", v[0], v[1], v[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Like in libc. */
|
/** Like in libc. */
|
||||||
|
|||||||
@@ -541,17 +541,17 @@ public class PrintfFormat {
|
|||||||
* Integer, Long, Float, Double, and Character
|
* Integer, Long, Float, Double, and Character
|
||||||
* arguments are treated as wrappers for primitive
|
* arguments are treated as wrappers for primitive
|
||||||
* types.
|
* types.
|
||||||
* @param o The array of objects to format.
|
* @param objs The array of objects to format.
|
||||||
* @return The formatted String.
|
* @return The formatted String.
|
||||||
*/
|
*/
|
||||||
public String sprintf(Object[] o) {
|
public String sprintf(Object... objs) {
|
||||||
Enumeration<Object> e = vFmt.elements();
|
Enumeration<Object> elements = vFmt.elements();
|
||||||
ConversionSpecification cs = null;
|
ConversionSpecification cs = null;
|
||||||
char c = 0;
|
char c = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
while (e.hasMoreElements()) {
|
while (elements.hasMoreElements()) {
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
cs = (ConversionSpecification) elements.nextElement();
|
||||||
c = cs.getConversionCharacter();
|
c = cs.getConversionCharacter();
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
sb.append(cs.getLiteral());
|
sb.append(cs.getLiteral());
|
||||||
@@ -562,212 +562,46 @@ public class PrintfFormat {
|
|||||||
i = cs.getArgumentPosition() - 1;
|
i = cs.getArgumentPosition() - 1;
|
||||||
if (cs.isPositionalFieldWidth()) {
|
if (cs.isPositionalFieldWidth()) {
|
||||||
int ifw = cs.getArgumentPositionForFieldWidth() - 1;
|
int ifw = cs.getArgumentPositionForFieldWidth() - 1;
|
||||||
cs.setFieldWidthWithArg(((Integer) o[ifw]).intValue());
|
cs.setFieldWidthWithArg((Integer) objs[ifw]);
|
||||||
}
|
}
|
||||||
if (cs.isPositionalPrecision()) {
|
if (cs.isPositionalPrecision()) {
|
||||||
int ipr = cs.getArgumentPositionForPrecision() - 1;
|
int ipr = cs.getArgumentPositionForPrecision() - 1;
|
||||||
cs.setPrecisionWithArg(((Integer) o[ipr]).intValue());
|
cs.setPrecisionWithArg((Integer) objs[ipr]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cs.isVariableFieldWidth()) {
|
if (cs.isVariableFieldWidth()) {
|
||||||
cs.setFieldWidthWithArg(((Integer) o[i]).intValue());
|
cs.setFieldWidthWithArg((Integer) objs[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (cs.isVariablePrecision()) {
|
if (cs.isVariablePrecision()) {
|
||||||
cs.setPrecisionWithArg(((Integer) o[i]).intValue());
|
cs.setPrecisionWithArg((Integer) objs[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (o[i] instanceof Byte)
|
if (objs[i] instanceof Byte)
|
||||||
sb.append(cs.internalsprintf(((Byte) o[i]).byteValue()));
|
sb.append(cs.internalsprintf(((Byte) objs[i]).byteValue()));
|
||||||
else if (o[i] instanceof Short)
|
else if (objs[i] instanceof Short)
|
||||||
sb.append(cs.internalsprintf(((Short) o[i]).shortValue()));
|
sb.append(cs.internalsprintf(((Short) objs[i]).shortValue()));
|
||||||
else if (o[i] instanceof Integer)
|
else if (objs[i] instanceof Integer)
|
||||||
sb.append(cs.internalsprintf(((Integer) o[i]).intValue()));
|
sb.append(cs.internalsprintf(((Integer) objs[i]).intValue()));
|
||||||
else if (o[i] instanceof Long)
|
else if (objs[i] instanceof Long)
|
||||||
sb.append(cs.internalsprintf(((Long) o[i]).longValue()));
|
sb.append(cs.internalsprintf(((Long) objs[i]).longValue()));
|
||||||
else if (o[i] instanceof Float)
|
else if (objs[i] instanceof Float)
|
||||||
sb.append(cs.internalsprintf(((Float) o[i]).floatValue()));
|
sb.append(cs.internalsprintf(((Float) objs[i]).floatValue()));
|
||||||
else if (o[i] instanceof Double)
|
else if (objs[i] instanceof Double)
|
||||||
sb.append(cs.internalsprintf(((Double) o[i]).doubleValue()));
|
sb.append(cs.internalsprintf(((Double) objs[i]).doubleValue()));
|
||||||
else if (o[i] instanceof Character)
|
else if (objs[i] instanceof Character)
|
||||||
sb.append(cs.internalsprintf(((Character) o[i]).charValue()));
|
sb.append(cs.internalsprintf(((Character) objs[i]).charValue()));
|
||||||
else if (o[i] instanceof String)
|
else if (objs[i] instanceof String)
|
||||||
sb.append(cs.internalsprintf((String) o[i]));
|
sb.append(cs.internalsprintf((String) objs[i]));
|
||||||
else
|
else
|
||||||
sb.append(cs.internalsprintf(o[i]));
|
sb.append(cs.internalsprintf(objs[i]));
|
||||||
if (!cs.isPositionalSpecification())
|
if (!cs.isPositionalSpecification())
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Format nothing. Just use the control string.
|
|
||||||
* @return the formatted String.
|
|
||||||
*/
|
|
||||||
public String sprintf() {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Format an int.
|
|
||||||
* @param x The int to format.
|
|
||||||
* @return The formatted String.
|
|
||||||
* @exception IllegalArgumentException if the
|
|
||||||
* conversion character is f, e, E, g, G, s,
|
|
||||||
* or S.
|
|
||||||
*/
|
|
||||||
public String sprintf(int x) throws IllegalArgumentException {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
else
|
|
||||||
sb.append(cs.internalsprintf(x));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Format an long.
|
|
||||||
* @param x The long to format.
|
|
||||||
* @return The formatted String.
|
|
||||||
* @exception IllegalArgumentException if the
|
|
||||||
* conversion character is f, e, E, g, G, s,
|
|
||||||
* or S.
|
|
||||||
*/
|
|
||||||
public String sprintf(long x) throws IllegalArgumentException {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
else
|
|
||||||
sb.append(cs.internalsprintf(x));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Format a double.
|
|
||||||
* @param x The double to format.
|
|
||||||
* @return The formatted String.
|
|
||||||
* @exception IllegalArgumentException if the
|
|
||||||
* conversion character is c, C, s, S,
|
|
||||||
* d, d, x, X, or o.
|
|
||||||
*/
|
|
||||||
public String sprintf(double x) throws IllegalArgumentException {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
else
|
|
||||||
sb.append(cs.internalsprintf(x));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Format a String.
|
|
||||||
* @param x The String to format.
|
|
||||||
* @return The formatted String.
|
|
||||||
* @exception IllegalArgumentException if the
|
|
||||||
* conversion character is neither s nor S.
|
|
||||||
*/
|
|
||||||
public String sprintf(String x) throws IllegalArgumentException {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
else
|
|
||||||
sb.append(cs.internalsprintf(x));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Format an Object. Convert wrapper types to
|
|
||||||
* their primitive equivalents and call the
|
|
||||||
* appropriate internal formatting method. Convert
|
|
||||||
* Strings using an internal formatting method for
|
|
||||||
* Strings. Otherwise use the default formatter
|
|
||||||
* (use toString).
|
|
||||||
* @param x the Object to format.
|
|
||||||
* @return the formatted String.
|
|
||||||
* @exception IllegalArgumentException if the
|
|
||||||
* conversion character is inappropriate for
|
|
||||||
* formatting an unwrapped value.
|
|
||||||
*/
|
|
||||||
public String sprintf(Object x) throws IllegalArgumentException {
|
|
||||||
Enumeration<Object> e = vFmt.elements();
|
|
||||||
ConversionSpecification cs = null;
|
|
||||||
char c = 0;
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
cs = (ConversionSpecification) e.nextElement();
|
|
||||||
c = cs.getConversionCharacter();
|
|
||||||
if (c == '\0')
|
|
||||||
sb.append(cs.getLiteral());
|
|
||||||
else if (c == '%')
|
|
||||||
sb.append("%");
|
|
||||||
else {
|
|
||||||
if (x instanceof Byte)
|
|
||||||
sb.append(cs.internalsprintf(((Byte) x).byteValue()));
|
|
||||||
else if (x instanceof Short)
|
|
||||||
sb.append(cs.internalsprintf(((Short) x).shortValue()));
|
|
||||||
else if (x instanceof Integer)
|
|
||||||
sb.append(cs.internalsprintf(((Integer) x).intValue()));
|
|
||||||
else if (x instanceof Long)
|
|
||||||
sb.append(cs.internalsprintf(((Long) x).longValue()));
|
|
||||||
else if (x instanceof Float)
|
|
||||||
sb.append(cs.internalsprintf(((Float) x).floatValue()));
|
|
||||||
else if (x instanceof Double)
|
|
||||||
sb.append(cs.internalsprintf(((Double) x).doubleValue()));
|
|
||||||
else if (x instanceof Character)
|
|
||||||
sb.append(cs.internalsprintf(((Character) x).charValue()));
|
|
||||||
else if (x instanceof String)
|
|
||||||
sb.append(cs.internalsprintf((String) x));
|
|
||||||
else
|
|
||||||
sb.append(cs.internalsprintf(x));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*<p>
|
*<p>
|
||||||
* ConversionSpecification allows the formatting of
|
* ConversionSpecification allows the formatting of
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 General Public License for more details.
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package lwjake2.util;
|
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vargs is a helper class to encapsulate printf arguments.
|
|
||||||
*
|
|
||||||
* @author cwei
|
|
||||||
*/
|
|
||||||
public class Vargs {
|
|
||||||
|
|
||||||
// initial capacity
|
|
||||||
static final int SIZE = 5;
|
|
||||||
|
|
||||||
Vector<Object> v = null;
|
|
||||||
|
|
||||||
public Vargs() {
|
|
||||||
this(SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs(int initialSize) {
|
|
||||||
if (v != null)
|
|
||||||
v.clear(); // clear previous list for GC
|
|
||||||
v = new Vector<>(initialSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(boolean value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(byte value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(char value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(short value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(int value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(long value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(float value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(double value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(String value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs add(Object value) {
|
|
||||||
v.add(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vargs clear() {
|
|
||||||
v.clear();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This apparently isn't even used? - flibit
|
|
||||||
public Vector toVector() {
|
|
||||||
// Vector tmp = v;
|
|
||||||
// v = null;
|
|
||||||
// return tmp;
|
|
||||||
return (Vector) v.clone();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Object[] toArray() {
|
|
||||||
return v.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
|
||||||
return v.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user