Bitwise Shift Operands

Is there any way to accomplish this with XPRESS or do I have to engineer Java code and call it via <Action><expression><invoke> ...
[156 byte] By [Joseph.Smitha] at [2007-11-27 7:29:02]
# 1
I think Java code. Or that is how I do all my math, shift and anything else calculated with arithmetic.I often wonder why XPRESS, I am hoping Sun moves this to straight up Java Script or Java code some day. <> are useless keys to press so often. Makes me hate XML.
dmander2a at 2007-7-12 19:09:11 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

Hi dmander2,

as the forms and workflows are xmlObjects but not xpress replacing xpress would not really help. Plus you can do a lot with some fantasy, invoke and new:

<invoke name="matches">

<ref>date</ref>

<s>(((0[1-9]|[12][0-9]|3[01])([.])(0[13578]|10|12)([.])(\d{4}))|(([0][1-9]|[12][0-9]|30)([.])(0[469]|11)([.])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([.])(02)([.])(\d{4}))|((29)(\.|-|\/)(02)([.])([02468][048]00))|((29)([.])(02)([.])([13579][26]00))|((29)([.])(02)([.])([0-9][0-9][0][48]))|((29)([.])(02)([.])([0-9][0-9][2468][048]))|((29)([.])(02)([.])([0-9][0-9][13579][26])))</s>

</invoke>

validates a date in dd.mm.yyyy format taking leap years into account.

Yes it does work but no i'm not seriously thinking it is a good way to solve the problem :)

About Josephs problem i am not really sure. Simple shifting could always be done by multiplications or divisions by 2. While not as efficient that could be done in xpress. But for similar tasks like analyzing and modifying userAccountControl i used java in the past.

/**

* Tests if a certain bit is set within the String representation

* of a number ( userAccountControl ).

*

* Examples:

*"128","8"equates to null

*"127","16"equates to "true"

*

* @param String value representing a long integer.

* @param String bit representing the bit to test.

*

* @return String "true" if the bit is set, null otherwise.

*/

public static String testBit(String value, String bit)

{

long l = (new Long(value)).longValue();

long b = (new Long(bit)).longValue();

return ((l & b) == 0) ? "true":null;

}

/**

* Sets one or more bits (logical or) within a number.

*

* Examples:

*"128","8"equates to "136"

*"127","16"equates to "127"

*

* @param String value representation of a long integer.

* @param String bit representation of the bits to set

*

* @return (value OR bit) as a number in String representation.

*/

public static String setBit(String value, String bit)

{

long l = (new Long(value)).longValue();

long b = (new Long(bit)).longValue();

return String.valueOf(l | b);

}

/**

* Cleares one or more bits within a number

*

* Examples:

*"128","8"equates to "128"

*"127","16"equates to "111"

*

* @param String value representation of a long integer.

* @param String bit representation of the bits to set

*

* @return value with bit cleared.

*/

public static String clearBit(String value, String bit)

{

long l = (new Long(value)).longValue();

long b = (new Long(bit)).longValue();

return String.valueOf(l - (l & b));

}

Regards,

Patrick

Patrick.Wehingera at 2007-7-12 19:09:11 > top of Java-index,Web & Directory Servers,Directory Servers...