Updated docs to reflect the changes in 1.5.4
git-svn-id: https://j8583.svn.sourceforge.net/svnroot/j8583/j8583@99 db60a039-f72e-0410-b1d2-baa000846441
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
-----
|
||||
Groovy compatibility
|
||||
Polyglot compatibility
|
||||
-----
|
||||
|
||||
Isn't ANY Java library compatible with Groovy?
|
||||
Groovy compatibility
|
||||
|
||||
* Isn't ANY Java library compatible with Groovy?
|
||||
|
||||
Yes, of course. You can use j8583 in Groovy just as you would use any other Java library. However,
|
||||
some j8583 classes have certain methods in them written specifically for usage within Groovy.
|
||||
@@ -33,3 +35,36 @@ def value = message[32]?.value
|
||||
to <<<getField()>>> and <<<setField>>>, and the IsoType class has two <<<call()>>> methods, with and without
|
||||
length, which return IsoValue instances with the proper type and length. The variant that has a length parameter
|
||||
must be used with NUMERIC and ALPHA types, and the other types can use the variant without length.
|
||||
|
||||
Scala compatibility
|
||||
|
||||
In a similar fashion, you can use a shorter notation in Scala to set and get fields:
|
||||
|
||||
+-----
|
||||
message(32) = IsoType.LLVAR("Some value")
|
||||
message(7) = IsoType.DATE10(new Date())
|
||||
message(41) = IsoType.ALPHA("Term", 16)
|
||||
message(11) = IsoType.NUMERIC(123, 6)
|
||||
val v1:String = message(32).getValue
|
||||
val v2:String = message.getObjectValue(32)
|
||||
+-----
|
||||
|
||||
This is because IsoMessage also implements the <<<apply()>>> and <<<update()>>> methods that work similarly to <<<getField()>>> and <<<setField()>>>. Also, IsoType now implements <<<apply()>>> so that you can create IsoValues from IsoTypes.
|
||||
|
||||
Builder Pattern
|
||||
|
||||
In any language, you can use the builder pattern, since now the <<<setValue>>> and <<<setField>>> methods return the message itself:
|
||||
|
||||
+-----
|
||||
message.setValue(4, amount, IsoType.AMOUNT, 12)
|
||||
.setValue(7, new Date(), IsoType.DATE, 10)
|
||||
.setValue(11, trace, IsoType.NUMERIC, 6);
|
||||
+-----
|
||||
|
||||
Of course it can be more succing in Groovy or Scala:
|
||||
|
||||
+-----
|
||||
message.setField(4, IsoType.AMOUNT(amount))
|
||||
.setField(7, IsoType.DATE(new Date()))
|
||||
.setField(11, IsoType.NUMERIC(trace, 6))
|
||||
+-----
|
||||
@@ -1,36 +0,0 @@
|
||||
-----
|
||||
Compatibilidad con Groovy
|
||||
-----
|
||||
|
||||
¿Qué no cualquier biblioteca de Java es compatible con Groovy?
|
||||
|
||||
Por supuesto. Se puede utilizar j8583 en Groovy al igual que cualquier otra biblioteca de Java. Sin embargo,
|
||||
algunas clases de j8583 tienen algunos métodos con el expreso propósito de ser utilizados desde Groovy.
|
||||
|
||||
* Atajos de j8583 en Groovy
|
||||
|
||||
En Java, se pueden manejar los valores de un IsoMessage en alguna de las siguientes formas:
|
||||
|
||||
+-----
|
||||
message.setValue(32, "Algun valor", IsoType.LLVAR, 0);
|
||||
IsoValue isoValue = message.getField(32);
|
||||
String value = (String)message.getObjectValue(32);
|
||||
Object value2 = message.getField(32).getValue();
|
||||
+-----
|
||||
|
||||
En Groovy se puede hacer lo mismo de esta forma:
|
||||
|
||||
+-----
|
||||
message[32] = IsoType.LLVAR("Algun valor")
|
||||
message[7] = IsoType.DATE10(new Date())
|
||||
message[41] = IsoType.ALPHA("Term", 16)
|
||||
message[11] = IsoType.NUMERIC(123, 6)
|
||||
IsoValue isoValue = message[32]
|
||||
def value = message[32]?.value
|
||||
+-----
|
||||
|
||||
Esto es posible gracias a que la clase IsoMessage implementa los métodos <<<getAt()>>> y <<<putAt()>>>, que
|
||||
funcionan de manera similar a <<<getField()>>> y <<<setField()>>>; la clase IsoType tiene dos variantes del
|
||||
método <<<call()>>>, una con longitud y otra sin longitud, los cuales devuelven instancias de IsoValue con
|
||||
el valor y longitud apropiados. La variante con longitud debe ser utiliza para crear valores tipo
|
||||
NUMERIC y ALPHA, mientras que los demás tipos pueden utilizar la variante sin longitud.
|
||||
@@ -0,0 +1,71 @@
|
||||
-----
|
||||
Compatibilidad Políglota
|
||||
-----
|
||||
|
||||
Compatibilidad con Groovy
|
||||
|
||||
* ¿Qué no cualquier biblioteca de Java es compatible con Groovy?
|
||||
|
||||
Por supuesto. Se puede utilizar j8583 en Groovy al igual que cualquier otra biblioteca de Java. Sin embargo,
|
||||
algunas clases de j8583 tienen algunos métodos con el expreso propósito de ser utilizados desde Groovy.
|
||||
|
||||
* Atajos de j8583 en Groovy
|
||||
|
||||
En Java, se pueden manejar los valores de un IsoMessage en alguna de las siguientes formas:
|
||||
|
||||
+-----
|
||||
message.setValue(32, "Algun valor", IsoType.LLVAR, 0);
|
||||
IsoValue isoValue = message.getField(32);
|
||||
String value = (String)message.getObjectValue(32);
|
||||
Object value2 = message.getField(32).getValue();
|
||||
+-----
|
||||
|
||||
En Groovy se puede hacer lo mismo de esta forma:
|
||||
|
||||
+-----
|
||||
message[32] = IsoType.LLVAR("Algun valor")
|
||||
message[7] = IsoType.DATE10(new Date())
|
||||
message[41] = IsoType.ALPHA("Term", 16)
|
||||
message[11] = IsoType.NUMERIC(123, 6)
|
||||
IsoValue isoValue = message[32]
|
||||
def value = message[32]?.value
|
||||
+-----
|
||||
|
||||
Esto es posible gracias a que la clase IsoMessage implementa los métodos <<<getAt()>>> y <<<putAt()>>>, que
|
||||
funcionan de manera similar a <<<getField()>>> y <<<setField()>>>; la clase IsoType tiene dos variantes del
|
||||
método <<<call()>>>, una con longitud y otra sin longitud, los cuales devuelven instancias de IsoValue con
|
||||
el valor y longitud apropiados. La variante con longitud debe ser utiliza para crear valores tipo
|
||||
NUMERIC y ALPHA, mientras que los demás tipos pueden utilizar la variante sin longitud.
|
||||
|
||||
Compatibilidad con Scala
|
||||
|
||||
De manera similar, se puede usar una notación más breve en Scala para fijar y obtener valores de un mensaje:
|
||||
|
||||
+-----
|
||||
message(32) = IsoType.LLVAR("Some value")
|
||||
message(7) = IsoType.DATE10(new Date())
|
||||
message(41) = IsoType.ALPHA("Term", 16)
|
||||
message(11) = IsoType.NUMERIC(123, 6)
|
||||
val v1:String = message(32).getValue
|
||||
val v2:String = message.getObjectValue(32)
|
||||
+-----
|
||||
|
||||
Esto es posible gracias a que IsoMessage también ya implementa los métodos <<<apply()>>> y <<<update()>>>, que invocan internamente a <<<setField()>>> y <<<getField()>>>. Asimismo, IsoType implementa <<<apply()>>> para que se puedan crear IsoValues a partir de IsoTypes.
|
||||
|
||||
Patrón Constructor
|
||||
|
||||
En cualquier lenguaje, se puede utilizar el patrón constructor, gracias a que ahora los métodos <<<setField()>>> y <<<setValue()>>> devuelven el mensaje sobre el que se invocan, lo que permite encadenar varias llamadas:
|
||||
|
||||
+-----
|
||||
message.setValue(4, amount, IsoType.AMOUNT, 12)
|
||||
.setValue(7, new Date(), IsoType.DATE, 10)
|
||||
.setValue(11, trace, IsoType.NUMERIC, 6);
|
||||
+-----
|
||||
|
||||
Por supuesto, en Groovy y Scala puede ser más breve todavía:
|
||||
|
||||
+-----
|
||||
message.setField(4, IsoType.AMOUNT(amount))
|
||||
.setField(7, IsoType.DATE(new Date()))
|
||||
.setField(11, IsoType.NUMERIC(trace, 6))
|
||||
+-----
|
||||
+3
-3
@@ -15,14 +15,14 @@
|
||||
<item name="Download" href="http://sourceforge.net/projects/j8583/files/j8583/"/>
|
||||
</links>
|
||||
|
||||
<menu name="j8583 1.5.1">
|
||||
<menu name="j8583 1.5.4">
|
||||
<item name="Introduction" href="index.html"/>
|
||||
<item name="API docs" href="apidocs/index.html" />
|
||||
<item name="API docs" href="javadoc/index.html" />
|
||||
<item name="Beginner's Guide" href="guide.html"/>
|
||||
<item name="ISO8583" href="iso8583.html" />
|
||||
<item name="XML config" href="xmlconf.html" />
|
||||
<item name="Spring Example" href="spring.html"/>
|
||||
<item name="Groovy Compatibility" href="groovy.html" />
|
||||
<item name="Polyglot Compat" href="polyglot.html" />
|
||||
<item name="Download" href="http://sourceforge.net/projects/j8583/files/j8583/" />
|
||||
<item name="Español" href="/es/index.html" />
|
||||
</menu>
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
<item name="Descargar" href="http://sourceforge.net/projects/j8583/files/j8583/"/>
|
||||
</links>
|
||||
|
||||
<menu name="j8583 1.5.1">
|
||||
<menu name="j8583 1.5.4">
|
||||
<item name="Introducción" href="index.html"/>
|
||||
<item name="Documentación API" href="../apidocs/index.html" />
|
||||
<item name="Documentación API" href="../javadoc/index.html" />
|
||||
<item name="Guía de inicio" href="guide.html"/>
|
||||
<item name="ISO8583" href="iso8583.html" />
|
||||
<item name="XML config" href="xmlconf.html" />
|
||||
<item name="Ejemplo con Spring" href="spring.html"/>
|
||||
<item name="Compatibilidad con Groovy" href="groovy.html" />
|
||||
<item name="Compatibilidad Políglota" href="polyglot.html" />
|
||||
<item name="Descargar" href="http://sourceforge.net/projects/j8583/files/j8583/" />
|
||||
<item name="English" href="../index.html" />
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user