A fairly simple string manipulation, I think!

Hi, would be most grateful for some help on the following as
getting close, but can't quite master it.
I have thousands of records in one field in a sql 2000
database in the following format
racehorsename odds-odds-odds (country) i.e Stravinsky 3-9-7
(USA)
Basically I want to move the country from the end of the
string to in between horesname and odds
so result on above would look like Stravinsky (USA) 3-9-7
A few point to note
The odds can either be in "x-x" or "x-x-x" format or a not
present (in which case no action required)
County maybe a variation from 3 or 2 digits i.e (USA) or (UK)
or not present at all in whihc case no action required
many thanks
Oli

there may be a more elegant solution (probably involving
regex), but assuming there's little to no variance in the syntax,
use list functions with a space as a delimiter.
<cfset foo = "Stravinsky 3-9-7 (USA)" />
<cfset newfoo = listFirst(foo, ' ') & listLast(foo, '
') & listGetAt(foo, 2, ' ') />
odds being x-x or x-x-x wouldn't matter. length of country
abbreviation wouldn't matter. all that would matter would be the
inclusion of additional spaces (like if the horse name has a space
in it).

Similar Messages

  • How to make a fairly simple keyword structure for a amateur shooter?

    Hi,
    I am trying to find a clever way of keywording my images, and have found the hierarchy that comes standard with Aperture to be unsuitable for my needs.
    I was hoping to share some ideas on how to build a suitable general structure for someone (amateur) that may end up shooting pictures of almost anything. Once again - I am looking for a fairly simple structure that I might actually end up using and not the pro huge hierarchies that some pro shooters use.
    So far, I have identified 3 main questions that I think keywords should answer:
    1. What (description of situation)
    2. Where (location, as spesific as possible, even if some off my photos has got gps data in them)
    3. Who (names, but also classified into family, friends, collegues, anonymous)
    Elabourating on this list, the next branch could perhaps be:
    1.What
    1.1
    1.2 ?
    1.3 ?
    1.4 ...
    Some ideas on categories here are: Work/Leisure, arts/crafts,
    2. Where
    2.1 Country
    2.2 County
    2.3 District
    2.4 Place/location
    3. Who
    3.1 Family
    3.2 Friends
    3.3 Collegues
    3.4 Anonymous
    I would love input on this topic and I would also like the hierarchy be expandable.
    Would also love to know where I can find more information on this topic for amateurs like myself.
    Best regards,
    Kjell Are Refsvik

    An intensity graph is just a 2D array. All you need is initialize a 2D integer array of sufficient size and keep it in a shift register. Increment elements based on the xy coordinates.
    For some ideas, have a look at this old example.
    LabVIEW Champion . Do more with less code and in less time .

  • Simple audio question (I think)

    Thanks everyone for answering this question which I think is fairly simple. I have a new TV that I use as the monitor for my computer and connect my Itv to. Currently I have both the cable, my computer and ITV hooked up through HDMI. Whenever I switch between the different HDMI inputs I obviously do not continue getting the sound out from my ITV. The question is I would like to be able to leave my ITV running while it is playing music to my stereo and surf the internet with my computer output on the screen. I know I could obviously play Itunes on my computer however the ITV seems to have much better output quality. Anyone has a solution for this?
    I look forward to your answers. Have a great day and thanks again.
    Message was edited by: mameares

    Welcome to the  Discussion Forums.
    Not without some other device to feed audio through. Your tv will only play from one input at a time, when you switch to the input from your mac/pc, it will always cut off the audio from other inputs.

  • Any ideas for a (fairly) simple program?

    Does anybody have any ideas for a fairly simple program that I could try to write (I am a fair programmer, but I'm not to creative)?

    You know, Java Game Programming for Dummies is actually a pretty good book (despite the "Dummies" part!) It is written in 1.0, but it has a "ponglet", card games, and several maze games. All the applets I've tried from them actually work (some typos in the book itself, but the CD is ok). Any of these could be "starter" code.
    Yahoo has a whole bunch of Java applet games. You could try to reproduce pieces of the games you see. (These are also interesting in the sense that you can immediately see what works in a game and what doesn't.)
    It is always fun to write little components. Cool buttons (write a nice little non-rectangular button that lights up or something), text boxes that look like digital displays, funny text labels (maybe with a weird font or with letters that jump all over the place when you mouse over them).. These don't take a whole lot of time to write, but write them well and they are very useful for your future games.
    Enjoy!
    :) jen

  • String Manipulation in BI Publisher Report Paramater

    Hi,
    My Problem is that I am not able to do string manipulation on BI Publisher report Prameters.
    Actually I want to Show Deptno-Dname in Menu(LOV).and when I select Certain combination like '10-Accounting',and while passing the parameter:Dept I wanted to Cut the department no(10) using string manipulation functions provided by oracle in Data Model(Query) in where clause like (where deptno=to_number(substr(:Dept,1,2)).
    This query is working fine in other application like TOAD,But not giving results in BI Publisher Report.
    It's also not giving any error while saving or running the report.
    Please suggest any solution.

    even I tried the following query in data model..
    select DISTINCT EMP.EMPNO as EMPNO,
    EMP.ENAME as ENAME,
    EMP.JOB as JOB,
    DEPT.LOC as LOC
    from SCOTT.DEPT DEPT,
    SCOTT.EMP EMP
    where emp.DEPTNO=DEPT.deptno
    and DEPT.deptno=nvl(to_number(substr(:department,1,2)),DEPT.deptno)
    But the Parameter which I want to pass say Department('10-Accounting'),
    Still it is showing employees from all departments.

  • How to escape string that SQLCMD thinks is a variable but isn't.

    Hi All,
    I've got a SQLCMD script where I use :setvar like I usually do.  As part of its work it calls a stored procedure that has a parameter whose value is a string.  Part of the string being passed looks like this. 
    Objects="$(INSTANCE)"
    Now my SQLCMD script is throwing and error like the following.
    A fatal scripting error occurred.
    Variable INSTANCE is not defined.
     How do I  escape that $(INSTANCE) inside the string that SQLCMD thinks is a variable for it to use so that the string gets loaded into the table as it supposed to be?  I'm failing to find how to escape
    a variable that isn't actually a variable.
    Joe
    Joe Moyle

    To anyone interested I was able to solve this.  In the string being passed in as a parameter I was able to replace the $ with
    +
    CHAR(36)
    +
    and it works perfectly.
    Joe Moyle

  • String manipulation in JSTL

    Hello All
    I'm a just a beginner and I'm need to write a web page that is totally based on JSTL. I found out that the standard java tab lib in JSTL doesnt really support string manipulation or regular expression like in perl.
    As such, I would like to know what are the different options (like adding servlets/javabeans/etc) can i add to my JSTL page so that i can perform complex string manipulation to a data entered by the user in the text box?
    Some of the operations that I wish to carry out on the data are:
    1. check if data contains certain characters, strings
    2. joining and spliting strings
    3. find length of the string
    4. find the position of certain character in a string
    5. check if string match certain pattern.
    and many more.
    Would greatly appreciate if you guys can help to provide some light.
    Regards
    Beginner....

    You might find MicroNova YUZU JSP tag library (http://sourceforge.net/projects/micronova-yuzu) useful, especially if you need to support both JSP 1.2 and 2.0. Hope this helps.

  • Hey guys. I want to connect my MacBook to my Samsung television and don't know what cable to purchase. It's a five year old machine and I presume a fairly simple solution but would appreciate it if someone could link me up to the correct cable to buy.

    Hey guys. I want to connect my MacBook to my Samsung television and don't know what cable to purchase. It's a five year old machine and I presume a fairly simple solution but would appreciate it if someone could link me up to the correct cable to buy.
    Thanks,
    Todd
    UK

    Depends on what input plug you'll be using on your TV. VGA, DVI, Composite or HDMI. You'll need a Mini-DVI adapter and a cable from that to your TV. Here's the various types of Mini-DVI adapters on Amazon.com http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=min i-dvi&x=9&y=13
    (Composite is the red, white and yellow RCA plugs on your TV or red, white and S-Video plugs.)
    You'll also need audio cables to the TV using a 3.5mm stereo headphone jack to RCA sound plugs for VGA, DVI or Composite. You attach it from the headphone jack of your MacBook to the appropriate input plugs on your TV http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=min i-dvi&x=9&y=13#/ref=nb_sb_ss_i_2_19?url=search-alias%3Daps&field-keywords=macbo o k+audio+cable&sprefix=macbook+audio+cable&rh=i%3Aaps%2Ck%3Amacbook+audio+cable
    If you connect the MacBook using a Mini-DVI to HDMI adapter you will probably need to use external speakers or a 3.5mm stereo headphone jack to RCA sound plugs connected to a stereo system for audio if your TV doesn't have separate RCA input plugs or a 3.5mm stereo input plug for audio with the HDMI plug. The Mini-DVI to HDMI doesn't carry audio and there're no audio plugs on most TVs to work with HDMI since it's expecting audio with the HDMI.

  • Simple String Compression Functions

    Hi all !
    I need two simple String compression functions, like
    String compress(String what)
    and
    String decompress(String what)
    myString.equals(decompress(compress(myString)))
    should result in true.
    Primarily I want to encode some plain text Strings so they are not too easy to read, and compression would be a nice feature here.
    I already tried the util.zip package, but that one seems to need streams, I simply need Strings.
    Any ideas ??
    thx
    Skippy

    It does not do any compression, in fact it does
    expansion to better encrypt the string (about 50%).How does that work? You want encryption to
    decrease entropy.Why in the world do you say that, pjt33? What a very odd statement indeed. I sure hope you don't work in security, or I do hope you work in security if I'm a bad guy, or a competitor.
    Let's say you had a 6-character string you wanted to encrypt.
    Well, if you didn't increase the entropy, any 6-character plaintext string would have a 6-character encoded equivalent. And if you decreased entropy (e.g. coding the most commonly used words to shorter strings,) it gets even easier to decrypt.
    Presumably there would be no hash collisions, after all, you want this to be reversible.
    Hash collisions decrease entropy too, and, by doing so, make it easier to find a plaintext string that happens to hash to a certain value. This is a Bad Thing.
    Now, to decode this, the Bad Guy only has to consider the set of 6-character strings and their hash values. You could even precalculate all of the common dictionary words, and everything with common letters and punctuation, making decryption virtually instantaneous. Especially if you had decreased the entropy in the signal, making fewer things I had to try.
    But somebody who increased the entropy of their signal by adding random bits and increasing the encrypted size of the message to, say, 64 characters, would make it a lot harder to decrypt.
    The ideal encryption system is pure noise; pure randomized entropy. An indecipherable wall of 0 and 1 seemingly generated at random. Statistical methods can't be used against it; nothing can be deciphered from it; it's as decipherable and meaningless as radio hiss. Now that's encryption!

  • Simple Stream/String Manipulation

    I have a data stream that I am feeding into a method as a string, connects to a DB2 database and inserts the values contained in the string. Here is what the string looks like:
    ==SS39939294==
    03012|39|33|32|2|232|9995
    0333|34|007|32|2|7|95345
    0392|39|33|32|2|232|9995
    04492|39|3|32|8|77|95175
    0392|39|33|6|2|232|554I need to "trim" out the stamp (==SS39939294==), which represents the Unix time of the stream. I believe i will need to use the replaceAll method of the String class with a regular expression, but i'm not quite sure how to do that. Can anyone help?
    Thank you!

    Thank you both!
    I tried to read each line individually and filter them accordingly, but, no luck. Here is most of the code from method run():
              while (true) {
                   if (listenPort == null) {
                        logIt("listenPort is null");
                        return;
                   try {
                        clientConn = listenPort.accept();
                        clientHost = clientConn.getInetAddress().getHostName();
                        logIt("client connection accepted");
                        BufferedReader myRcv = new BufferedReader (
                             new InputStreamReader(clientConn.getInputStream()));
                        timeout = Integer.parseInt(
                                       System.getProperty("noDataTO", TIMEOUT));
                        clientConn.setSoTimeout(timeout*1000);
                        //boolean eof = false;
                        //while (!eof) {
                             //String rcvLine = myRcv.readLine();
                             //if (rcvLine != null){
                                            //long e__tm = Long.parseLong(rcvLine.substring(5,9));
                                            //SockServer.j_Insertion(rcvLine);
                             //else {
                             //     eof = true;
                                    String line;
                                    while ( (line = myRcv.readLine() ) != null )
                                    if (! line.startsWith("=="));
                                            SockServer.j_Insertion(line);
                        logIt("connection dropped by client");
                        clientHost = null;
                        logIt("listening on port: " + portArg);
                   } catch (InterruptedIOException ioe) {
                        logIt("IO ERROR: (cliento) " + ioe.getMessage());
                        logIt("restarting...");
                   } catch (IOException ioe) {
                        logIt("IO ERROR: (client) " + ioe.getMessage());
                        logIt("exiting...");
                        System.exit(1);
                   } finally {
                        try {
                             clientConn.close();
                        } catch (IOException ioe) {
                             logIt("ERROR: clientConn.close() failed - "
                                        + ioe.getMessage());
                             logIt("exiting...");
                             System.exit(1);
         }Obviously I pass the string to the j_Insertion method and println().
    The stream still comes through with the leading timestamp (as well as a ==START== and ==END== tags, which i was able to remove via replace before)
    Thanks!

  • Write a simple string to a file.

    I have a string that is formatted with new lines that I want to write to a file as is. I have not been able to create a File Partner Link that can successfully write the content.
    The opaque approach creates an empty file.
    I have tried defining a new schema as a string, a delimited and a fixed length and the closest I have come is getting the last line written with fixed length.
    This is the input schema. I want to write the file element. The complex_child element contains values I would use to build the file name.
    <xs:complexType name="complex_parent_type">
    <xs:sequence>
    <xs:element name="complex_child" type="ns1:complex_child_type"/>
    <xs:element name="file" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    Anybody have any success? I would think this should be a simple process. We would prefer not to use embedded Java.
    Thanks,
    Wes.

    Hi Wes,
    You could try using this schema:
    <?xml version="1.0" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="..."
    xmlns:tns="..."
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    nxsd:encoding="US-ASCII" nxsd:stream="chars"
    nxsd:version="NXSD" >
    <xsd:element name="file" type="xsd:string" nxsd:style="terminated"
                                  nxsd:terminatedBy="${eof}">
    </xsd:element>
    </xsd:schema>
    You could copy over the contents of the string that you want to write out into the element above and then use the "invoke" on a file adapter PL to write it out.
    Regards,
    Narayanan

  • Simple problem? I think so!

    Hey folks I got a problem I did not expect because before it worked quite good :-)
    I got an jsp page with buttons "ny" for next year and "py" for previous year and the same for day (nd...) and month. the point is, after pressing the ohne of the buttons, in order to change the date an exception occurs, I really dont understand why.
    First here is the error message:
    org.apache.jasper.JasperException: null
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:367)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.lang.NumberFormatException: null
         java.lang.Integer.parseInt(Integer.java:436)
         java.lang.Integer.parseInt(Integer.java:518)
         org.apache.jsp.eintragen_jsp._jspService(eintragen_jsp.java:64)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    Second the script for the Eintragen.jsp with date adjusting posibility, which isn�t working:
    <begins here>
    <HTML>
    <HEAD>
    <TITLE>Calendar: Termin eintragen</TITLE>
    </HEAD>
    <BODY BGCOLOR="white">
    <tr><td>Sie wollen 1 Seiten eingeben</td></tr><br>
    <tr><td>1</td></tr>
    <tr><td>Page Title:</td><td><INPUT NAME="p_title" TYPE=TEXT SIZE=50 maxlength=200></td></tr><br>
    <table>
    <tr><td>Page Level:</td><td><SELECT size="4" name="p_level"><br>
    <OPTION value="1">Level 1</OPTION>
    <OPTION value="2">Level 2</OPTION>
    <OPTION value="3">Level 3</OPTION>
    <OPTION value="4">Level 4</OPTION>
    <OPTION value="5">Level 5</OPTION>
    <OPTION value="6">Level 6</OPTION>
    <OPTION value="7">Level 7</OPTION>
    <OPTION value="8">Level 8</OPTION>
    <OPTION value="9">Level 9</OPTION>
    </SELECT></td></tr><br>
    <tr><td></td></tr>
    </table>
    <tr><td>Page Content Owner:</td><td><INPUT NAME="p_co" TYPE=TEXT SIZE=50 maxlength=200></td></tr><br>
    <tr><td>Page Review Date:</td><br><br>
    <td><button type="input" OnClick="self.location.href='add?date=py'">py</button></td>
    <td><button type="input" OnClick="self.location.href='add?date=pm'">pm</button></td>
    <td><button type="input" OnClick="self.location.href='add?date=pd'">pd</button></td>
    <td><b>2004-05-28</b>
    <INPUT NAME="p_review" TYPE="HIDDEN" value="2004-05-28"></td>
    <td><button type="input" OnClick="self.location.href='add?date=nd'">nd</button></td>
    <td><button type="input" OnClick="self.location.href='add?date=nm'">nm</button></td>
    <td><button type="input" OnClick="self.location.href='add?date=ny'">ny</button></td>
    </tr>
    </BODY>
    </HTML>
    <ends here>
    Then I have a Java class calbean.java which delegates date adjustments to JspCalendar. In turn the Eintragen.jsp should retrieve the adjusted date from calbean.java:
    <calbean begins here>
    package webeng;
    import java.beans.*;
    import java.util.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class calBean {
    JspCalendar JspCal;
    String date;
    public calBean () {
    this.JspCal = new JspCalendar();
    this.date = JspCal.getDate();
    public String getDate () {
    return this.date;
    public void setDate (HttpServletRequest request) {
    String dateR = request.getParameter ("date");
    if (dateR == null) date = JspCal.getDate ();
    else if (dateR.equalsIgnoreCase("ny")) date = JspCal.getNextYear ();
    else if (dateR.equalsIgnoreCase("nm")) date = JspCal.getNextMonth ();
    else if (dateR.equalsIgnoreCase("nd")) date = JspCal.getNextDay ();
    else if (dateR.equalsIgnoreCase("py")) date = JspCal.getPreviousYear ();
    else if (dateR.equalsIgnoreCase("pm")) date = JspCal.getPreviousMonth ();
    else if (dateR.equalsIgnoreCase("pd")) date = JspCal.getPreviousDay ();
    <calbean ends here>
    And here I have the JspCalendar which computes dates which works I think, also the calbean because when Eintragen.jsp is first started I got the current date(today) only adjustments are not possible:
    <JspCalendar starts here>
    * JspCalendar.java
    * Created on 09. Mai 2004, 22:10
    package webeng;
    import java.text.DateFormat;
    import java.util.*;
    public class JspCalendar {
    Calendar calendar = null;
    Date currentDate;
    int reiter = 0;
    public JspCalendar() {
         calendar = Calendar.getInstance();
         Date trialTime = new Date();
         calendar.setTime(trialTime);
    public int getYear() {
         return calendar.get(Calendar.YEAR);
    public String getMonthe() {
         int m = getMonthInt();
         String[] months = new String [] { "January", "February", "March",
                             "April", "May", "June",
                             "July", "August", "September",
                             "October", "November", "December" };
         if (m > 12)
         return "Unknown to Man";
         return months[m - 1];
    public String getDay() {
         int x = getDayOfWeek();
         String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday",
                        "Thursday", "Friday", "Saturday"};
         if (x > 7)
         return "Unknown to Man";
         return days[x - 1];
    public int getMonthInt() {
         return 1 + calendar.get(Calendar.MONTH);
    public String getDate() {
    int i = getDayOfMonth();
    int j = getMonthInt();
    if ( i < 10 && j < 10 ) {
         return getYear()+"-0"+getMonthInt()+"-0"+getDayOfMonth();     
    else if (i < 10 && (j > 10 || j == 10)) {
    return getYear()+"-"+getMonthInt()+"-0"+getDayOfMonth();
    else if ((i > 10 || i == 10) && j < 10) {
    return getYear()+"-0"+getMonthInt()+"-"+getDayOfMonth();
    else return getYear()+"-"+getMonthInt()+"-"+getDayOfMonth();
    public String getNextDay() {
    calendar.set (Calendar.DAY_OF_MONTH, getDayOfMonth() + 1);
    return getDate ();
    public String getPreviousDay() {
    calendar.set (Calendar.DAY_OF_MONTH, getDayOfMonth() - 1);
    return getDate ();
    public String getPreviousMonth() {
    calendar.set (Calendar.MONTH, getMonth() - 1);
    return getDate ();
    public String getNextMonth() {
    calendar.set (Calendar.MONTH, getMonth() + 1);
    return getDate ();
    public String getNextYear() {
    calendar.set (Calendar.YEAR, getYear() + 1);
    return getDate ();
    public String getPreviousYear() {
    calendar.set (Calendar.YEAR, getYear() - 1);
    return getDate ();
    public int getMonth() {
    return calendar.get(Calendar.MONTH);
    public String getTime() {
         return getHour() + ":" + getMinute() + ":" + getSecond();
    public int getDayOfMonth() {
         return calendar.get(Calendar.DAY_OF_MONTH);
    public int getDayOfYear() {
         return calendar.get(Calendar.DAY_OF_YEAR);
    public int getWeekOfYear() {
         return calendar.get(Calendar.WEEK_OF_YEAR);
    public int getWeekOfMonth() {
         return calendar.get(Calendar.WEEK_OF_MONTH);
    public int getDayOfWeek() {
         return calendar.get(Calendar.DAY_OF_WEEK);
    public int getHour() {
         return calendar.get(Calendar.HOUR_OF_DAY);
    public int getMinute() {
         return calendar.get(Calendar.MINUTE);
    public int getSecond() {
         return calendar.get(Calendar.SECOND);
    public int getEra() {
         return calendar.get(Calendar.ERA);
    public String getUSTimeZone() {
         String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
                        "Mountain", "Central", "Eastern"};
         return zones[10 + getZoneOffset()];
    public int getZoneOffset() {
         return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
    public int getDSTOffset() {
         return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
    public int getAMPM() {
         return calendar.get(Calendar.AM_PM);
    public int getDaysPerMonth() {
    return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    <JspCalendar ends here>
    I don�t think solving the problem is a big deal, only obviously I am not capable doing it in the moment.
    Please help me!
    Johannes

    The exception is telling you what to look for:
    java.lang.NumberFormatException: null
    java.lang.Integer.parseInt(Integer.java:436)
    java.lang.Integer.parseInt(Integer.java:518)
    It's even telling you WHERE to look:
    eintragen_jsp.java:64
    Line 64 of that .java file is where you'll find the answer.
    Why do you need JspCalendar? Seems like most of the functionality you put into it is already available in java.util.Calendar. (I just gave it a quick look.)

  • Most efficient way to do some string manipulation

    Greetings,
    I need to cleanse some data in a string by replacing unsafe characters with encoded equivalents. (FYI, this is for the purpose of transforming "unsafe" characters into encoded values as data inside an XML document).
    The following code accomplishes the task:
    Note that a string "currentValue" contains the data to be cleansed.
    A string, "encodedValue" contains the result.
      for (counter = 0; counter < currentValue.length(); counter++)
        addChar = (currentValue.substring(counter,counter+1));
        if (addChar.equals("<"))
          addChar = "#60;";
        if (addChar.equals(">"))
          addChar = "#62;";
        if (addChar.equals("="))
          addChar = "#61;";
        if (addChar.equals("\""))
          addChar = "#34;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("/"))
          addChar = "#47;";
        if (addChar.equals("\\"))
          addChar = "#92;";
        encodedValue += addChar;
      } // forI'm sure there is a way to make this more efficient. I'm not exactly "new" to java, but I am learning on my own with no formal training and often take a "brute force" approach with my initial effort.
    What would be the most efficient way to re-do the above?
    TIA,
    --Paul Galvin
    Integrated Systems & Services Group

    im a c++ programmer so im not totally up on these java classes either but...from a c++ stand point you might want to consider using the if else statment.
    by using if else, you only test the character until you find the actual "violating" character and skip the rest of the tests.
    also, you might trying using something to check for alphaNumeric cases first and use the continue keyword when you find one. since more of your characters are probably safe than unsafe you can skip all the ifs/if else statement and only do one test on the good characters. (i just looked for a way to test that and i didnt find one. c++ has a function that does that by checking the ascii number range. dont think that works in java. but maybe you can find one, it would reduce the number of tests probably.)
    happy hunting,
    txjump :)

  • Cross-DOM API and/or Techniques for simple image manipulation

    Am I correct in assuming that Cross-DOM API calls presume the target application is running? That is, these calls are not out to a "shared" library so to speak, but actually communication between two running apps.
    Assuming that is the case, is there any way, within Bridge itself, to do simple manipulations on files, such as scaling, and file type conversion. Am I required to have photoshop running to do this?

    Not sure on which platform you are using, and hoping it is not for hires/hiquality purposes, but you could use one of the many engines, for example the AppleScript Graphic Core.
    If you want/have to use PhotoShop, for what I know it has to be running.
    Bye!

  • String manipulation question (servlet)

    Hello,
    I have a problem replacing parts of a String with values from a HttpServletRequest.
    I have the following method:
    public String replaceVariables(String s, HttpServletRequest request) {
         Enumeration e = request.getParameterNames();
         Vector v = new Vector();
         while(e.hasMoreElements()) {
              v.add(e.nextElement());
         String paramName;
         ListIterator li = v.listIterator();
         while(li.hasNext()) {
              paramName = (String) li.next();
              if (s.indexOf("#" + paramName + "#") > -1) {
                   s = new String(new StringBuffer(s).replace(s.indexOf("#" + paramName + "#"), s.indexOf("#" + paramName + "#") + (("#" + paramName + "#").length()), request.getParameter(paramName).toString()));
         return s;
    }What I am trying to do here is read in a line of text (String s) along with a the htpp servlet request. Put the names of the request paramaters into Vector v.
    Next I try to check the String s for any part of the String that matches one of the parameter names surrounded by #'s. If there is a match then I replace the #string# with the value associated with it in the http servlet request.
    The trouble is, my code on ly replaces the very first variable then stops, I cannot see why it does not do the rest.
    I hope this makes sense to somebody, becuase it doesn't to me :-)
    Thanks for any advise or help

    Yep. I have just done a basic one for testing. The String I read in is:
    username = #username#, action = #action#, email = #email#
    And the html form information that is sent to the servlet is:
    <input type="hidden" name="action" value="test">
    <input type="hidden" name="username" value="testuser">
    <input type="hidden" name="email" value="testemail">
    ....etc.
    I don't know if it makes a difference, I don;t think it does, but I am reading in a whole file, and passing the file line by line to this method.
    The method that passes each line is:
    public Vector generateHTML(HttpServletRequest request) {
         Vector v = new Vector();
         try {
              File f = new File("/fakepath/" + request.getParameter("action") + ".template");
              FileReader fr = new FileReader(f);
              BufferedReader br = new BufferedReader(fr);
              String s;
              while((s = br.readLine()) != null) {
                   s = replaceVariables(s, request);
                   v.add(s);
         } catch (Exception e) {
              // ignore
         } finally {
              return v;
    }

Maybe you are looking for

  • Bug in java.awt.geom.Rectangle2D.contains method

    I cannot understand why not awt.geom.Rectangle2D.contains() return the right value??? Or maybe i don�t understand it properly. Check out this code snippet import java.awt.geom.*; public class Test     public static void main(String[] args)        //R

  • What Happens to Me after 6/30/12?  My devices are not supported!!!

    What Happens to Me after 6/30/12?  Do I get to keep my @me.com address from MobileMe because My Mac, PC nor iOS device is supported by iCloud On 6/30/12 All ACTIVE MobileMe accounts that havn't MOVED to iCloud will be deleted as MobileMe is no longer

  • Are there any known reviewers of ibook titles?

    After wrestling through all the issues and challenges of publishing several robust iBooks (can I use that word here?), I am faced with the issue of making my contributions known to the waiting world. I've scoured the Internet and have not yet discove

  • Run-time connection load balancing

    Hello! I'm using jdbc thin client (10g) and I'm trying to improve connection pool management. I would like to enable run-time connection load balancing. Is this option available with Fast Connection failover? Basically when a a client requests a conn

  • My Dock doesn't work

    I have seen this on other posts but have yet to read a answer that works on this issue. With my dock hiding I can not use the mouse to view the items on the dock while its hiding. I can restart the machine and it will work for a while but then goes b