Is there a better way to do this with Flash?

I am new to Flash but am slowly teaching myself via Lynda.com etc
I have an image that I have added to a website via a content management system and want to make certain areas of that image into links to other sites.
I found this page that does the kind of thing I want to do, but it appears from looking at the source code that the person who has done this has cut the image up into several sections in order to fit it into a table: http://www3.imperial.ac.uk/staffdevelopment/postdocs1/guidance
Is there a better way to achieve the same kind of effect using Flash by making ares of an image into links and keeping the image as a whole?

There are ways to keep the image whole and have portions of it linking to different places both in HTML and in Flash.  In HTML you can use an image map.  In Flash, you can just lay invisible buttons atop the image and use those to link.

Similar Messages

  • I am having trouble transferring files from an old MacBook (2007) to a MacBook Air over a wireless network.  The connection was interrupted and the time was over 24 hours.  Is there a better way to do this?  I'm using Migration assistant.

    I am having trouble transferring files from an old MacBook (2007) to a MacBook Air over a wireless network.  The connection was interrupted and the time was over 24 hours.  Is there a better way to do this?  I'm using Migration assistant.  The lack of an ethernet port on MacBook air does not help.

    William ..
    Alternative data transfer methods suggested here > OS X: How to migrate data from another Mac using Mavericks

  • Is there a better way to do this projection/aggregate query?

    Hi,
    Summary:
    Can anyone offer advice on how best to use JDO to perform
    projection/aggregate queries? Is there a better way of doing what is
    described below?
    Details:
    The web application I'm developing includes a GUI for ad-hoc reports on
    JDO's. Unlike 3rd party tools that go straight to the database we can
    implement business rules that restrict access to objects (by adding extra
    predicates) and provide extra calculated fields (by adding extra get methods
    to our JDO's - no expression language yet). We're pleased with the results
    so far.
    Now I want to make it produce reports with aggregates and projections
    without instantiating JDO instances. Here is an example of the sort of thing
    I want it to be capable of doing:
    Each asset has one associated t.description and zero or one associated
    d.description.
    For every distinct combination of t.description and d.description (skip
    those for which there are no assets)
    calculate some aggregates over all the assets with these values.
    and here it is in SQL:
    select t.description type, d.description description, count(*) count,
    sum(a.purch_price) sumPurchPrice
    from assets a
    left outer join asset_descriptions d
    on a.adesc_no = d.adesc_no,
    asset_types t
    where a.atype_no = t.atype_no
    group by t.description, d.description
    order by t.description, d.description
    it takes <100ms to produce 5300 rows from 83000 assets.
    The nearest I have managed with JDO is (pseodo code):
    perform projection query to get t.description, d.description for every asset
    loop on results
    if this is first time we've had this combination of t.description,
    d.description
    perform aggregate query to get aggregates for this combination
    The java code is below. It takes about 16000ms (with debug/trace logging
    off, c.f. 100ms for SQL).
    If the inner query is commented out it takes about 1600ms (so the inner
    query is responsible for 9/10ths of the elapsed time).
    Timings exclude startup overheads like PersistenceManagerFactory creation
    and checking the meta data against the database (by looping 5 times and
    averaging only the last 4) but include PersistenceManager creation (which
    happens inside the loop).
    It would be too big a job for us to directly generate SQL from our generic
    ad-hoc report GUI, so that is not really an option.
    KodoQuery q1 = (KodoQuery) pm.newQuery(Asset.class);
    q1.setResult(
    "assetType.description, assetDescription.description");
    q1.setOrdering(
    "assetType.description ascending,
    assetDescription.description ascending");
    KodoQuery q2 = (KodoQuery) pm.newQuery(Asset.class);
    q2.setResult("count(purchPrice), sum(purchPrice)");
    q2.declareParameters(
    "String myAssetType, String myAssetDescription");
    q2.setFilter(
    "assetType.description == myAssetType &&
    assetDescription.description == myAssetDescription");
    q2.compile();
    Collection results = (Collection) q1.execute();
    Set distinct = new HashSet();
    for (Iterator i = results.iterator(); i.hasNext();) {
    Object[] cols = (Object[]) i.next();
    String assetType = (String) cols[0];
    String assetDescription = (String) cols[1];
    String type_description =
    assetDescription != null
    ? assetType + "~" + assetDescription
    : assetType;
    if (distinct.add(type_description)) {
    Object[] cols2 =
    (Object[]) q2.execute(assetType,
    assetDescription);
    // System.out.println(
    // "type "
    // + assetType
    // + ", description "
    // + assetDescription
    // + ", count "
    // + cols2[0]
    // + ", sum "
    // + cols2[1]);
    q2.closeAll();
    q1.closeAll();

    Neil,
    It sounds like the problem that you're running into is that Kodo doesn't
    yet support the JDO2 grouping constructs, so you're doing your own
    grouping in the Java code. Is that accurate?
    We do plan on adding direct grouping support to our aggregate/projection
    capabilities in the near future, but as you've noticed, those
    capabilities are not there yet.
    -Patrick
    Neil Bacon wrote:
    Hi,
    Summary:
    Can anyone offer advice on how best to use JDO to perform
    projection/aggregate queries? Is there a better way of doing what is
    described below?
    Details:
    The web application I'm developing includes a GUI for ad-hoc reports on
    JDO's. Unlike 3rd party tools that go straight to the database we can
    implement business rules that restrict access to objects (by adding extra
    predicates) and provide extra calculated fields (by adding extra get methods
    to our JDO's - no expression language yet). We're pleased with the results
    so far.
    Now I want to make it produce reports with aggregates and projections
    without instantiating JDO instances. Here is an example of the sort of thing
    I want it to be capable of doing:
    Each asset has one associated t.description and zero or one associated
    d.description.
    For every distinct combination of t.description and d.description (skip
    those for which there are no assets)
    calculate some aggregates over all the assets with these values.
    and here it is in SQL:
    select t.description type, d.description description, count(*) count,
    sum(a.purch_price) sumPurchPrice
    from assets a
    left outer join asset_descriptions d
    on a.adesc_no = d.adesc_no,
    asset_types t
    where a.atype_no = t.atype_no
    group by t.description, d.description
    order by t.description, d.description
    it takes <100ms to produce 5300 rows from 83000 assets.
    The nearest I have managed with JDO is (pseodo code):
    perform projection query to get t.description, d.description for every asset
    loop on results
    if this is first time we've had this combination of t.description,
    d.description
    perform aggregate query to get aggregates for this combination
    The java code is below. It takes about 16000ms (with debug/trace logging
    off, c.f. 100ms for SQL).
    If the inner query is commented out it takes about 1600ms (so the inner
    query is responsible for 9/10ths of the elapsed time).
    Timings exclude startup overheads like PersistenceManagerFactory creation
    and checking the meta data against the database (by looping 5 times and
    averaging only the last 4) but include PersistenceManager creation (which
    happens inside the loop).
    It would be too big a job for us to directly generate SQL from our generic
    ad-hoc report GUI, so that is not really an option.
    KodoQuery q1 = (KodoQuery) pm.newQuery(Asset.class);
    q1.setResult(
    "assetType.description, assetDescription.description");
    q1.setOrdering(
    "assetType.description ascending,
    assetDescription.description ascending");
    KodoQuery q2 = (KodoQuery) pm.newQuery(Asset.class);
    q2.setResult("count(purchPrice), sum(purchPrice)");
    q2.declareParameters(
    "String myAssetType, String myAssetDescription");
    q2.setFilter(
    "assetType.description == myAssetType &&
    assetDescription.description == myAssetDescription");
    q2.compile();
    Collection results = (Collection) q1.execute();
    Set distinct = new HashSet();
    for (Iterator i = results.iterator(); i.hasNext();) {
    Object[] cols = (Object[]) i.next();
    String assetType = (String) cols[0];
    String assetDescription = (String) cols[1];
    String type_description =
    assetDescription != null
    ? assetType + "~" + assetDescription
    : assetType;
    if (distinct.add(type_description)) {
    Object[] cols2 =
    (Object[]) q2.execute(assetType,
    assetDescription);
    // System.out.println(
    // "type "
    // + assetType
    // + ", description "
    // + assetDescription
    // + ", count "
    // + cols2[0]
    // + ", sum "
    // + cols2[1]);
    q2.closeAll();
    q1.closeAll();

  • Is there a better way to do this? Interactive graphics on a PDF

    Hello
    Part of a PDF form I am planning requires the user to place several marks on a series of dots.
    I have partially achieved this using check boxes and many hidden objects.
    http://www.hoodoomayhem.com/example/Example.pdf focus on the small dots in the upper right.
    Is there a smarter way to achieve this without using thousands of hidden objects.
    I am quite new to scripting and do appreciate any suggestions.
    I look forward to some feedback
    Bonbeket

    That update should only be a single statement - not within a loop. The basic structure here should be something like:
    update central_printing_staging cps
       set sent_for_printing_date = trim(sysdate)
    where central_printing_staging_id in (select ...
                                             from <variation of complex query>);
    open p_centralprinting_refcursor
    for <complex query snipped>;The only question I have is whether the ref cursor is supposed to reflect the updated values or not, or if the two are even related or not - can't tell without seeing the query.

  • Is there a better way to do this function?

    Hi,
    I was just wondering if someone can suggest a better way of doing the function I have attached below. Basically, it is counting pulses (falling edges) over a 250ms time period and converting that to speed. There seems to be some cases where it counts lesser pulses for a longer period than 250ms which results in lower speeds, but physically the device doesnt run any slower. Or sometimes speed is higher. This code was written by someone else and I am trying to work it better.
    V
    P.S. There is an overall master While loop.
    I may not be perfect, but I'm all I got!
    Attachments:
    counter_wait.JPG ‏87 KB

    VeeJay wrote:
    @ yamaeda what do you mean by coercion dots? Can you explain in simpler terms.? Thanks!
    V
    coercion dots are those red dots on your arithmatic functions. That means you are dividing data of different types. For instance I32 and U8 would give you a coercion dot. What you will want to do is right click your constants, choose representation->[data type]. Either that, or you can go to the numeric-> conversion pallette (i think) thats where it is and convert numbers using the primitives there.
    CLA, LabVIEW Versions 2010-2013

  • Is there a better way to do this?  CSS rules/Background image/tables

    Hi,
    I am designing a site and I have used a table for the banner.  Everytime a different page is displayed, the banner image changes.  I have created .html pages, and I have created a lot of css rules to change the background image.  I think there must be a more efficiant way to do this?
    http://www.taffyproductions.com/test/
    ALSO... I need to figure out how to make the links (hover/active states) work on all the pages... I figured it out on the index page, but I'm sure there is a better css rule?

    Put a div in the head section?  Surely you jest!
    But you do hint at the easy solution - just have an embedded stylesheet in the head of each page that changed the background image only on that page.  No need for any other complexities.
    In other words on page1, change this -
    <link href="outpost.css" rel="stylesheet" type="text/css" />
    </head>
    to this -
    <link href="outpost.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    table#banner { background-image:url(images/banner1.jpg); }
    </style>
    </head>
    and on page2 change it to this -
    <link href="outpost.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    table#banner { background-image:url(images/banner2.jpg); }
    </style>
    </head>
    etc.

  • Is there a better way of doing this?

    Finally managed to get navigation to work the way I want!!!
    But not being an expert at Oracle PL/SQL i'm sure this code could be written a better way.
    I'm currently looping through the sublinks twice, first time to get a count second time to display the actual links. the reason for this is the bottom link needs a different style. Anyway here is the code I am using:
    <oracle>
    declare
         x number;
         y number;
    begin
         x := 0;
         y := 0;
         for c1 in (
         select id, display_name, name
         from #owner#.WWSBR_ALL_FOLDERS
         where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
         order by display_name
         loop
                   x := x+1;
         end loop;     
         htp.p('<tr><td id="sidenavtop"><strong>#TITLE#</strong></td></tr>');
         for c1 in (
         select id, display_name, name
         from #owner#.WWSBR_ALL_FOLDERS
         where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
         order by display_name
         loop
                   y := y+1;
                   if x = y then
                        htp.p('<TR><TD id="sidenavbottom">'||c1.display_name||'</TD></TR>');
                   else
                        htp.p('<TR><TD id="sidenavitem">'||c1.display_name||'</TD></TR>');                    
                   end if;
         end loop;
    end;
    </oracle>

    Well, you could fetch the count into a local variable, e.g.
    SELECT count(*)
    INTO x
    FROM ...
    WHERE ...;
    and move on, but then you are doing two fetches. I'm really sleepy at the moment, so it's possible this is logically and syntactically fouled up, but another option may be:
    DECLARE
    CURSOR c1 IS
    select id, display_name, name
    from #owner#.WWSBR_ALL_FOLDERS
    where parent_id = #PAGE.PAGEID# and caid=1917 and DISPLAY_IN_PARENT_FOLDER = 1
    order by display_name;
    r1 c1%ROWTYPE;
    l_display_name wwsbr_all_folders.display_name%TYPE;
    BEGIN
    htp.p('<tr><td id="sidenavtop">#TITLE#</td></tr>');
    OPEN c1;
    FETCH c1 INTO r1;
    l_display_name := r1.display_name;
    --hang on to the display name
    WHILE c1%FOUND LOOP
    FETCH c1 INTO r1;
    --see if there's another row...
    IF c1%FOUND THEN
    --if so, ouput the current value of l_display_name as sidenavitem
    htp.p('<TR><TD id="sidenavitem">'|| l_display_name||'</TD></TR>');
    l_display_name := r1.display_name;
    ELSE
    --if not, output the current value of l_display_name as sidenavbottom
    htp.p('<TR><TD id="sidenavbottom">'|| l_display_name||'</TD></TR>');
    END IF;
    END LOOP;
    CLOSE c1;
    end;
    Hope this helps!
    -John
    Message was edited by:
    John Hopkins

  • Using empty interface -- is there a better way to do this?

    Hi,
    I have a set of classes in different projects that I'd like to be referenced together, although they have different methods depending on which project they're from. To do so, I've created an empty interface for each of these classes to implement, so I can return a similar type and then cast it however I need to based on which project I'm using.
    However, I feel the approach of creating an empty interface just isn't the best way to do this. I've looked into annotations, but I don't think they can solve my problem. I don't think I'm being too clear here, so let me give a brief example:
    Here is one of the interfaces I use:
    public interface IceClient {
         public IceOperations operations();
    }Here is the empty interface:
    public interface IceOperations {
    }I have a method which will return a type of IceOperations:
         public static synchronized IceOperations getOperations(String clientName) {
              if (clientMap.containsKey(clientName)) {
                   IceClient client = clientMap.get(clientName);
                   return client.operations();
              } else {
                   System.out.println("No client of that name is currently running.");
                   return null;
         }This is all fine and dandy. I need to instantiate a new IceOperations object in my client code as such, where operations is of type IceOperations:
    operations = new DiagOperations();And finally return it like this, where client.operations() returns a type of IceOperations:
         public DiagOperations operations() {
              return (DiagOperations)client.operations();
         }Anyway I hope that wasn't too confusing. I cannot think of a different way to do this. Is there some way I can do this with annotations? The only other thing I can think of is just returning Object, but that seems ... icky.
    If I need to be clearer, please let me know.
    Thanks

    JoachimSauer wrote:
    I didn't understand them to be trick questions, but rather serious invitations to question and verify your assumptions.
    It might be the fact that every current implementation implements Runnable for some reason (possibly because it starts a Thread on its own). But it's entirely possible that you can produce a completely different implementation that doesn't need the Runnable interface and still be conformant.
    If every implementation of X needs to implement Runnable, then it could be a sign of a slight design smell. Could you give an example where you think it's necessary?Every implementation of my "X" interface is basically a class that acts as a communicator/listener of sorts until it's stopped by the user, similar to a server socket. Sometimes, it has to sit there and wait for events, in which case it obviously must be in its own Thread. Other times it doesn't have to do this; however if I do not start it in its own Thread, I will have to continually stop and restart the communication to invoke operations on the server, which is inefficient.

  • Is there a better way to do this Update?

    Can you do the following in a better way, maybe by using some sort of join between table_a and table_b
    update
    table_a a
    set
    (column_1, column_2)
    =
    (select
    column_3, column_4
    from
    table_b b
    where
    b.column_5 = a.column_6)
    where
    a.column_7 = whatever

    First of all, i would like to ask "if all the rows presnet in table_a are also present in table_b (w.r.t some relation like b.column_5 = a.column_6 in your example ???" If your answer is no, then your query is WRONG...it will update all records of table_a (that have a.column_7 = whatever) irrespective of whether they exist in table_b or not. There are two ways to do that
    (1)
    update table_a a
    set (column_1,column_2)=(select column_3,column_4 from table_b b where a.column_5=b.column_6)
    where exists (select null from table_b c where a.column_5=c.column_6)
    and a.column_7 = whatever
    (2)
    update
    (select column_1,column_2,column_3,column_4
    from table_a a, table_b b
    where a.column_5=b.column_6
    and a.column_7=whatever
    set column_1=column_3, column_2=column_4
    the second method wouldn't run untill you have a P.K on table_b(column_6)

  • Is there a better way to do this transformation

    I have the following code where I create a DOM and I transform it to text. My question since Im new to all this is if theres a cleaner way to capture the transformation and convert to a string that I need to include within the body of an email. Currently it seems like a waste to store the transformation into a text file and in turn do a .readLine() to obtain the contents. And I dont want to flush the output to the client by using an OutputStream or Writer. Thank you all for your time.
    Source xmlSource=new DOMSource(createDom());
    File file = new File("A:\\email.txt");
    Result result=new StreamResult(file);
    TransformerFactory transFact = TransformerFactory.newInstance();
    Transformer transformer = transFact.newTransformer(new StreamSource("A:\\xslTEXT.xsl"));
    transformer.transform(xmlSource, result);
    //redirect to email
    Mail mail = new Mail(file);

    If you look at the possible StreamResult constructors in the API documentation you'll see that a File is only one of many things you can pass in there. One of the other options is a Writer; if you create a StringWriter and wrap it in a StreamResult, then after your transformation is complete you can get its output as a String from that StringWriter.

  • Is there a better way of doing this? (multifileupload/forms/mysql)

    Hi all.
    I've managed to cobble together a page that will let me upload three files paths and three text boxes to a mysql database. the the files also go to specific directories depending on conditions.
    what im looking for is to see if there is a more efficient way of doing this. im mainly looking at the value and name strings along with the preparedstatement insert. i'd like to see if i can make it more dynamic so i don't have to predefine an amount anywhere.
    This code is working as is if anyone wants to use it in it's current state.
    here is the form
    <HTML>
      <HEAD>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>
        <TITLE>File Upload Page</TITLE>
      </HEAD>
      <BODY>Upload Files
        <FORM name="filesForm" action="uploadTestProccess.jsp" method="POST" enctype="multipart/form-data">
            File 1:<input type="file" name="file1"/><br/>
                File 2:<input type="file" name="file2"/><br/>
            File 3:<input type="file" name="file3"/><br/>
              text4: <input type="text" name="textField4" value="this is a test4"><br>
              text5: <input type="text" name="textField5" value="this is a test5"><br>
              text6: <input type="text" name="textField6" value="this is a test6"><br>
            <input type="submit" name="submit" value="Upload Files"/>
        </FORM>
      </BODY>
    </HTML>and here is the insert
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
    <%@ page import="org.apache.commons.fileupload.FileItem"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page import="java.util.List"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.io.File"%>
    <%@ page import="java.sql.*"%>
    <%!
    String value4;
    String value5;
    String value6;
    String name1;
    String name2;
    String name3;
    String dir;
    Connection dbconn;
    ResultSet result;
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <%
            //System.out.println("Content Type ="+request.getContentType());
            DiskFileUpload fu = new DiskFileUpload();
            // If file size exceeds, a FileUploadException will be thrown
            fu.setSizeMax(10000000);
            List fileItems = fu.parseRequest(request);
            Iterator itr = fileItems.iterator();
         for(int i=1; itr.hasNext(); i++){
                FileItem fi = (FileItem)itr.next();
                //Check if not form field so as to only handle the file inputs
                //else condition handles the submit button input
              if(!fi.isFormField()) {
                  out.print(i);
                //out.println("\nNAME: "+fi.getName());
                //out.println("SIZE: "+fi.getSize());
                   if(i==1){
                        name1 = fi.getName();
                        dir = "file1/";
                   } else if (i==2){
                        name2 = fi.getName();
                        dir = "file2/";
                   } else {
                        name3 = fi.getName();
                        dir = "file3/";
                File fNew= new File(application.getRealPath("examples1/" + dir), fi.getName());
                //out.println(fNew.getAbsolutePath());
                fi.write(fNew);
                   out.print("success<br>" + fi.getName() + "<br>");
                  } else {
                     //gets field names and values
                  // out.println("Field ="+fi.getFieldName());
                     String name      = fi.getFieldName();
                   if(i==4){
                        value4 = fi.getString();
                   } else if (i==5){
                        value5 = fi.getString();
                   } else if (i==6) {
                        value6 = fi.getString();
                   String value = fi.getString();
                    out.println("Found field with name <b>"+ name +"</b> and value <b>"+ value  +"</b><br>");
                   Class.forName("org.gjt.mm.mysql.Driver");
                   dbconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/xxx?user=root&password=xxx");
                   PreparedStatement sql = dbconn.prepareStatement("INSERT INTO uploadtest (file1, file2, file3, four, five, six) VALUES (?,?,?,?,?,?)");
                   sql.setString(1, name1);
                   sql.setString(2, name2);
                   sql.setString(3, name3);
                   sql.setString(4, value4);
                   sql.setString(5, value5);
                   sql.setString(6, value6);
                   int result = sql.executeUpdate();
              %>
    <body>
    <!--Upload Successful!!-->
    </body>
    </html>

    anyone?

  • Sharing is there a better way to do this?

    First time user of Pages (recently purch imac and have always used pc and office).
    So my scenerio is this:
    1.) I have a receipt that I have to send to a customer. I go online to our vendor my acct and get receipt. I see where I can click on many options such as "share", print to pdf, etc. Nothing to save in Pages though. Is there a way to do that where I can edit it after? If I could just directly share the receipt I would but I can not as there are other parts on receipt that does not belong to the customer I am trying to send receipt to. I tried in Pages just to save as pdf, but of course can not edit it.
    2.) I tried to "share" another page from a spreadsheet to same customer in an email...but the whole spredsheeet is sending in email. Can not figure out how to just send 1 page.
    3.) If I can finally get the receipt from online to pages, and only send that 1 page from the spreadsheet I now need to send another document. So my end goal and questions are how can I share via email 3 documents from different locations (Numbers & Pages) in one email? Provided I now have been able to figure out number 1.) above.
    Thanks so much
    Kimmie

    Yes.
    Log into iCloud.com. Look at the list of calendars. It works the same way for reminders.
    Click the icon to the right of the list name. Share it with whoever you want.

  • Is there a better way of doing this? (regards Entity Beans, CMP, J2EE5...)

    Hello everyone,
    So I'm going to blurt out two classes of code. First is a plain entity bean and the second is a helper class with two static methods to help me to convert Object into byte[] and vice versa without much worrying.
    Now the problem is, how to persist this entity bean and it's two Objects (two Lists) in a more "J2EE5 way". I just need to store these two Objects, or any Serializable Object, into persistent storage. So how to avoid this serialization by-hand that I'm doing... ?
    Thank you for your interest - and help :),
    Samuli
    Maybe using a @Lob notation or such? I've tried, but I can't get it workign. @Lob itself is not enough since it results in casting problems when retrieveing the data back from the persistent storage.
    And oh, I'm just using the simple CMP with this.. EJB using EntityManager's persist method to store and so on..
    EntityBean class (imports and packages excluded)
    @Entity
    public class MessageHandlerChain implements java.io.Serializable {
        @TableGenerator(
            name="messageHandlerChainIDGenerator",
            allocationSize=1,
            initialValue=1
        @GeneratedValue(
            generator="messageHandlerChainIDGenerator",
            strategy=GenerationType.TABLE
        @Id
        private Integer messageHandlerChainID;
        @Lob
        private byte[] messageHandlers;
        @Lob
        private byte[] messageHandlerProperties;
        @Transient
        private List<String> messageHandlersObj = new ArrayList<String>();
        @Transient
        private List<Map<String,String>> messageHandlerPropertiesObj = new ArrayList<Map<String,String>>();
         * Constructs an empty instance of <code>MessageHandlerChain</code> without any properties.
        public MessageHandlerChain() {
        public Integer getMessageHandlerChainID() {
            return messageHandlerChainID;
        public void setMessageHandlerChainID(Integer messageHandlerChainID) {
            this.messageHandlerChainID = messageHandlerChainID;
        public List<String> getMessageHandlers() {
            return messageHandlersObj;
        public void setMessageHandlers(List<String> messageHandlersObj) {
            if (messageHandlersObj == null) {
                System.out.println("[MessageHandlerChain] setMessageHandlers() can't be given a null value.");
                return;
            this.messageHandlersObj = messageHandlersObj;
        public List<Map<String,String>> getMessageHandlerProperties() {
            return messageHandlerPropertiesObj;
        public void setMessageHandlerProperties(List<Map<String,String>> messageHandlerPropertiesObj) {
            if (messageHandlerPropertiesObj == null) {
                System.out.println("[MessageHandlerChain] setMessageHandlerProperties() can't be given a null value.");
                return;
            this.messageHandlerPropertiesObj = messageHandlerPropertiesObj;
        @PrePersist
         * This method is invoked by the persistence provider prior to every persist operation.
         * This is needed because we need to convert, serialize, our <code>@Transient</code> annotated objects into <code>byte[]</code> streams
         * so that they can be written into the database.
        public void prePersist() {
            System.out.println("[MessageHandlerChain] prePersist()");
            if (messageHandlerPropertiesObj != null)
                messageHandlerProperties = BlobConverter.objectToBytes(messageHandlerPropertiesObj);
            if (messageHandlersObj != null)
                messageHandlers = BlobConverter.objectToBytes(messageHandlersObj);
        @PostLoad
         * This method is invoked by the persistence provider after every load operation.
         * This is needed because we need to convert, deserialize, <code>byte[]</code> streams back to our <code>@Transient</code> annotated objects.
        public void postLoad() {
            System.out.println("[MessageHandlerChain] postLoad()");
            try {
                if (messageHandlerProperties != null)
                    messageHandlerPropertiesObj = (List<Map<String,String>>)BlobConverter.bytesToObject(messageHandlerProperties);
                if (messageHandlers != null)
                    messageHandlersObj = (List<String>)BlobConverter.bytesToObject(messageHandlers);
            } catch (ClassCastException e) {
                System.out.println("[MessageHandlerChain] postLoad() Class Cast Exception: "+e);
        public String toString() {
            return "[MessageHandlerChain] messageHandlerChainID="+getMessageHandlerChainID()+", messageHandlers="+getMessageHandlers()+", messageHandlerProperties="+getMessageHandlerProperties();
    The helper class
    * <code>BlobConverter</code> is a simple helper class to encode and decode classes as byte[] so that they can be stored into persistent storage.
    * @author Samuli Piela
    public class BlobConverter {
        public static byte[] objectToBytes(Object o) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
            ObjectOutputStream oos = null;
            try {
                oos = new ObjectOutputStream(baos);
                oos.writeObject(o);
                return baos.toByteArray();
            } catch (InvalidClassException e) {
                System.out.println("objectToBytes("+o+"): Invalid Class: "+e);
            } catch (NotSerializableException e) {
                System.out.println("objectToByte("+o+"): Object not serializable: "+e);
            } catch (Exception e) {
                System.out.println("objectToBytes("+o+"): Exception: "+e);
            } finally {
                if (oos != null) {
                    try {
                        oos.close();
                    } catch (IOException e) {
                        System.out.println("objectToBytes(): Stream could not be closed: "+e);
                if (baos != null) {
                    try {
                        baos.close();
                    } catch (IOException e) {
                        System.out.println("objectToBytes(): Stream could not be closed: "+e);
                oos = null;
                baos = null;
            return null;
        public static Object bytesToObject(byte[] byteArray) {
            ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
            ObjectInputStream ois = null;
            try {
                ois = new ObjectInputStream(bais);
                Object o = ois.readObject();
                return o;
            } catch (ClassNotFoundException e) {
                System.out.println("bytesToObject(): Class not found: "+e);
            } catch (InvalidClassException e) {
                System.out.println("bytesToObject(): Invalid Class: "+e);
            } catch (IOException e) {
                System.out.println("bytesToObject(): IOException: "+e);
            } catch (Exception e) {
                System.out.println("bytesToObject(): Exception: "+e);
            } finally {
                if (ois != null) {
                    try {
                        ois.close();
                    } catch (IOException e) {
                        System.out.println("bytesToObject(): Stream could not be closed: "+e);
                if (bais != null) {
                    try {
                        bais.close();
                    } catch (IOException e) {
                        System.out.println("bytesToObject(): Stream could not be closed: "+e);
                ois = null;
                bais = null;
            return null;
    }

    anyone?

  • Verifying a String. Is there a better way to do this?

    Hi!!!
    Maybe for some of you this is obvious...
    I need to verify a String object. What I have to do is just a verification if there is a character different from 0 (zero) in a String. Then, the code would be something like this:
    String test = "00001";
    boolean ok = true;
    for (int i = 0 ; i < test.length ; i++) {
      if (test.charAt(i) != '0') {
        ok = false;
        break;
    }I want to know if there is another different solution, more appropriate, without using that for loop. Is there a magic method in Java that can do that verification?
    Thank you! ;-)

    (cue someone posting some regex foo that will dothis
    in one line of something that looks liketransmission
    line noise)Yeah, I've thought that. But, since I don't know
    anything about regex, well, I'll do some homeworks
    now...thank you!!!Your for loop is fine and much more efficient than any regex would be.

  • Is there a better way to do this? Binary File + MERGE

    Version
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Solaris: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Requirement
    I need to take binary files on a file system and a perform a MERGE in a destination table that has a blob column. This is a periodic task.
    My Version
    The following is a proof of concept that I've put together. I was wondering if anyone would be willing to critique this implementation or provide a better implementation to accomplish the same task.
    In reality the SOURCE table would be an external table that parses a control file that has a list of IDs and file names.
    DROP VIEW source_vw;
    DROP TABLE destination;
    DROP TABLE source;
    DROP FUNCTION get_blob;
    DROP PROCEDURE update_blobs;
    CREATE TABLE source
    ( id    NUMBER
    , fname VARCHAR2(255)
    INSERT INTO source
    ( id
    , fname
    SELECT rownum
         , 'Untitled.png'
    FROM   dual
    CONNECT BY level <= 5;
    CREATE TABLE destination
    ( id        NUMBER
    , file_data BLOB
    INSERT INTO destination(id, file_data) VALUES (1, EMPTY_BLOB());
    INSERT INTO destination(id, file_data) VALUES (3, EMPTY_BLOB());
    INSERT INTO destination(id, file_data) VALUES (5, EMPTY_BLOB());
    CREATE OR REPLACE FUNCTION get_blob
    ( p_dirname IN VARCHAR2
    , p_fname IN VARCHAR2
    RETURN BLOB
    AS
         b            BLOB;
         bf           BFILE;
         bfile_offset NUMBER :=1;
         blob_offset  NUMBER :=1;
    BEGIN
         DBMS_LOB.CREATETEMPORARY
         ( lob_loc => b
         , cache   => FALSE
         bf := BFILENAME(p_dirname,p_fname);
         DBMS_LOB.FILEOPEN(bf,DBMS_LOB.FILE_READONLY);
         DBMS_LOB.LOADBLOBFROMFILE(b,bf,DBMS_LOB.LOBMAXSIZE,bfile_offset,blob_offset);
         DBMS_LOB.FILECLOSE(bf);
         RETURN b;
    END get_blob;
    CREATE OR REPLACE VIEW source_vw
    AS
    SELECT id
         , GET_BLOB('SOME_DIR',fname) AS file_data
    FROM   source
    CREATE OR REPLACE PROCEDURE update_blobs
    AS
    BEGIN
         MERGE INTO destination
         USING source_vw
         ON    ( destination.id = source_vw.id )
         WHEN MATCHED THEN
             UPDATE SET destination.file_data = source_vw.file_data
         WHEN NOT MATCHED THEN
             INSERT
             ( id
             , file_data
             VALUES
             ( source_vw.id
             , source_vw.file_data
    END;
    /

    Because you are on 11.2, I would suggest switching to securefiles.
    CREATE TABLE destination
    ( id        NUMBER
    , file_data BLOB
    LOB(file_data) STORE AS SECUREFILE;

Maybe you are looking for