Typecast from Filename (String)  to IResource

Hello,
I want to use the Class importTaxonomy(IResource, IIndex).
The first Parameter is the name of the taxonomy itself, as XML File.
But before I can use the importTaxonomy Function I have to cast the String (name of the XML File) into an IResource Object.
Does anybody knows how I can create such an object from a filename?
Thank you.
Frank

Hi,
Try something like this:
IResourceContext context = new ResourceContext(user);
RID path = RID.getRID("/documents/src/ex1.xml");
IResource res = ResourceFactory.getInstance().getResource(path,context);
Best regards,
Avishai Zamir

Similar Messages

  • Building JTrees from Filename strings????

    Does anybody know or have code to build JTrees from fileName string so that the tree is expandable and uses expansion listeners.

    Does anybody have code that allows you to show the local filesystem and also file strings contained say in a file so they can both be viewed at the same time. ie if you know somebody else has a file but you want it reflected in your local filesystem.
    Come on somebody must

  • Getting filename from a string including filepath and filename

    How I can get a filename from a string which includes both
    filepath and filename? The filepath is not always the same. For
    example, the variable could include a "C:\temp\test.doc" or
    "C:\files\docfiles\test.doc" and I need to get the filename
    "test.doc" and save it to another variable. Thanks in
    advance.

    on getFilenameFromPath vPath
    oldDelim=the itemDelimiter
    the itemDelimiter=the last char of the moviePath
    iFilename=the last item of vPath
    the itemDelimiter=oldDelim
    return iFilename
    end
    Put that into a movie script. Then you can call the function
    any time
    to retrieve the last part of the path- like this:
    put getFilenameFromPath("C:\temp\test.doc")
    -- "test.doc"
    As an added bonus, it is cross-platform so it will work on a
    Mac as well
    as a PC.

  • Trying to get a date value from a string

    Hi All,
    I'm not sure I am doing this right, so I figured I would ask the experts...
    I have built a file upload page that is working the way I need it, but I have found that I need to determine the date from the uploaded file name. I tried to create a PL/SQL computation and do some substr / instr to the filename, but I'm not getting it as I get "ORA-01843: not a valid month" error. Here is the code I'm trying:
    declare
      v_underscore  integer;
      v_date            varchar2(15);  --have also tried using date datatype...
    begin
      v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
      v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');
      return v_date;
    end;And here is a sample filename:
    F15047/proc_10607161001.csv
    Is this the best way to achive what I'm trying to do?
    Thanks,
    Corey

    Hi,
    v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
    v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');What this is saying is:
    Get the position of the "_" character
    Move to the next character to the right (which is a "1" in your case)
    Get 6 characters (106071) from the string value
    Convert them to a date using the format 'YYMMDD'
    This results in:
    Year: 10
    Month: 60
    Day: 71
    Which of course is not valid.
    For example:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 1, 6)
    from
      dual;
    SUBSTR
    106071It looks like you want to move two positions to the right rather than a single position:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 2, 6)
    from
      dual;
    SUBSTR
    060716Hope that helps a bit,
    Mark

  • Automatic generation of enum members from name Strings

    I have a program in which I read information about Target objects from a text file. I store some of this information as an enum property of the target.
    }else if (itemKey.equalsIgnoreCase( "type")) {
    currentTarget.descriptor= itemValue;
    currentTarget.type = Target.getTargetType(currentTarget.descriptor);And elsewhere in the program I do the file reading and assignment of instance variables:
    class Target{
    enum TargetType {COUGH_DROP, RICE_CRACKER, PEPTO_BISMOL,UNDETERMINED};
    String descriptor;
    TargetType type;
    returns the target' s type as specified by a descriptor
    public static TargetType getTargetType (String descriptorString) {
    if (descriptorString.equals( "rice cracker")) {
    return (TargetType.RICE_CRACKER);
    } else if (descriptorString.equals ("cough drop")){
    return (TargetType.COUGH_DROP);
    } else if (descriptorString.equals ("Pepto-Bismol")){
    return (TargetType.PEPTO_BISMOL);
    } else {
    return (TargetType.UNDETERMINED);
    } I would like to be able to automatically generate the members of the TargetType enum from a list of strings as opposed to needing a method such as getTargetType above. Is this possible?
    Regards,
    Joe
    PS: I completely apologize for the appearance of the code above. I have no idea why this editor removed my indentation and added HTML markers. (I copied the code from a text editor, pasted into this editor, selected the code sections and clicked on the code button )
    PPS I now see that after a couple of switches between preview and rich text in the HTML markers have disappeared. WTF?

    I'm very curious to understand why one would like to create enum constants at run time? How can therse enums be used in the code that is not created at runtime? What are you really trying to achieve
    I know you marked your question as answered, but... you may have a look at the code below. It is a very very simple example of how to map real life descriptions (at runtime) to pre-existing enums. I didn't test it, but for all I know it should just work. Does this solve the problem that you are experiencing?
    import java.util.HashSet;
    import java.util.Set;
    public enum TargetType {
        RICE_CRACKER("C:/Descriptions/RiceCrackers.txt"),
        COUGH_DROP("C:/Descriptions/CouphDrops.txt"),
        PEPTO_BISMOL("C:/Descriptions/PeptoBismol.txt"),
        UNDETERMINED("C:/Descriptions/Empty.txt"),
        public static TargetType getType(String description) {
         for (TargetType targetType : TargetType.values()) {
             if (targetType.contains(description)) {
              return targetType;
         return UNDETERMINED;
        private final String fileName;
        private Set<String> descriptions = null;
        private TargetType(String fileName) {
         this.fileName = fileName;
        private boolean contains(String description) {
         if (descriptions == null) {
             descriptions = new HashSet<String>();
              * Populate descriptions from fileName.
         return descriptions.contains(description);
    }Piet

  • Create Business Partner from XMl String not a file

    Hi,
    Is it possible to create a BP from an XML string. 
    I know about GetBusinessPartnerFromXml(string FileName, int index)
    but I dont want to save the string in a file before creating a BP from it
    Hope there's a method to do that

    Marc,
    This looks like it is a duplicate of this post, so I am closing this thread as it looks like you answered your own question!
    Create Business Partner from XMl String not a file
    Eddy

  • How to  Remove the  Spc Char from a String ?

    Hi
    I am trying to stream out the file name after useing Timestamp. It throws some exception
    So I used the trim method for remove the space and spacial charater. But does't trim even space also.
    Please any body help me how to remove the space and spceial characters from my string.
    The file name ( String of value)
    2c5e773bad5e153cf91d7adabc121e62007-03-30 21:54:43.219.ivwr
    the file name after removing will be like this
    d2c5e773bad5e153cf91d7adabc121e620070330215443.ivwr
    pls help me
    Thanks,
    Merlin Roshina

    filename = filename.replaceAll("(?!\\.ivwr$)[- :.]","");

  • Replacing a set of characters from a string in oracle sql query

    I want to replace a set of characters ( ~    !     @    #     $     %     ^     *     /     \     +    :    ;    |     <     >     ?    _  ,) from a STRING in sql
    select 'TESTING ! ABC 123 #'
    FROM DUAL;
    What is the best way to do it? Please provide examples also.

    What is your expected output... The query I posted just removes them, it never replaces them with spaces..your string already has space.. if you want to remove space as well .. try this...
    SELECT TRANSLATE ('TESTING ! ABC 123 #', '-~!@#$%^*/\+:;|<>?_, ', ' ') FROM DUAL;
    Output:
    --TESTINGABC123
    Else post your expected output..
    Cheers,
    Manik.

  • Problems with Reflection API and intantiating an class from a string value

    I want to instantiate a class with the name from a String. I have used the reflection api so:
    static Object createObject(String className) {
    Object object = null;
    try {
    Class classDefinition = Class.forName(className);
    object = classDefinition.newInstance();
    } catch (InstantiationException e) {
    System.out.println(e);
    } catch (IllegalAccessException e) {
    System.out.println(e);
    } catch (ClassNotFoundException e) {
    System.out.println(e);
    return object;
    Let's say my class name is "Frame1".
    and then if i use:
    Frame1 frm = (Frame1) createObject("Frame1");
    everything is ok but i cannot do this because the name "Frame1" is a String variable called "name" and it doesn't work like:
    name frm = (name) createObject("Frame1");
    where i'm i mistaking?
    Thanks very much!

    i have understood what you have told me but here is a little problem
    here is how my test code looks like
    Class[] parameterTypes = new Class[] {String.class};
    Object frm = createObject("Frame1");
    Class cls = frm.getClass();
    cls.getMethod("pack",parameterTypes);
    cls.getMethod("validate",parameterTypes);
    everything works ok till now.
    usually if i would of had instantiated the "Frame1" class standardly the "cls" (or "frm" in the first question ) object would be an java.awt.Window object so now i can't use the function (proprietary):
    frame_pos_size.frame_pos_size(frm,true);
    this function requires as parameters: frame_pos_size(java.awt.Window, boolean)
    because my cls or frm objects are not java.awt.Window i really don't find any solution for my problem. I hope you have understood my problem. Please help. Thanks a lot in advance.

  • How can i store values from my String into Array

    Hi guys
    i wants to store all the values from my string into an array,,,, after converting them into intergers,,,, how i can do this becs i have a peice of code which just give me a value of a character at time,,,,charat(2)...BUT i want to the values from String to store in an Array
    here is my peice of code which i m using for 1 char at time
    int[] ExampleArray2 = new int[24];
    String tempci = "Battle of Midway";
    for(int i=0;i>=tempci.length();i++)
    int ascii = tempci.charAt(i); //Get ascii value for the first character.

    public class d1
         public static final void main( String args[] )
              int[] ExampleArray2 = new int[24];
              String tempci = "Battle of Midway";
              for(int i=0;i<tempci.length();i++)
                   int ascii = tempci.charAt(i);
                   ExampleArray2=ascii;
              for(int i=0;i<ExampleArray2.length;i++)
                   System.out.println(ExampleArray2[i]);

  • Getting char values from a string problem

    Hi,
    Here's an example of what I'm trying to do:
    boolean loopSwitch = true;
    while (loopSwitch)
         String orderDecider = JOptionPane.showInputDialog (null, "Would you like your numbers to be ordered in   ascending or descending order(A/D)",      "Order decision", JOptionPane.QUESTION_MESSAGE);
         if (orderDecider == A)
         loopSwitch = false;
         }I basically want the user to input either a/A/d/D and to get the char values from the string so I can use them in an if statement.
    Basically, I wanna parse the string into a char.
    Is this possible?
    Thanks.
    Edited by: xcd on Oct 16, 2009 8:38 AM

    Why not just use the String.equals() method to compare a String to a String?
    But if you must, you can use the String.charAt() method to return a char at a particular location in the String.
    Note: char literals need to be surrounded by single quotes ('A') and String literals need to be surrounded by double quotes ("A").

  • Removing Null values from character string

    Hi All,
    Can i remove NULL values (hexadecimal - 0000) from character string. I am uploading a file from presentation layer (shared server) and getting NULL values in many fields which i want to remove.
    please assist.
    Thanks for you help..
    Regards,
    Mohaiyuddin

    Hi,
    Most likely, nobody needed it, but if anybody in future will need the solution for related problem  - here's solution:
    data: lv_nullchar type xstring value '0'.
    shift lv_xstring right deleting trailing lv_nullchar in byte mode.
    shift lv_xstring left deleting leading lv_nullchar in byte mode.
    This hack deleting null chars in lv_xstring at end file and at begining of file. Works perfect for me, where i also worked with files.

  • How to get the Values i need from a String???

    hi i need some help on my program,
    I have a Server that actually sent some data to my Client.
    The data consist of some messages and intergers . The whole piece of data is stores as a String message.
    ARRAY 'Monitor Chart' 2 5
    'Total OverFlow' 'Queued' 'Completed' 'Host Resets' 'Errors'''
    0.0 1.0 2.0 3.0 4.0
    'Series1' 11.0 0.6 8.6 11.5 6.6
    'Series2' 12.8 6.7 21.6 11.1 30.0Inside the Client i need to get the values out to showed on my textfields
    Example :
    Tf1 = 11.0
    Tf2 = 0.6
    Tf3 = 8.6
    Tf4 = 11.5
    Tf5 = 6.6
    Question: How to i get the values out from the String???

    using the split() method. i am able to split everything now
    so it appear somthing like this :
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class testing{
         String d1 =     "ARRAY 'Monitor Chart' 1 5";
         String d2 = "'Total OverFlow' 'Queued' 'Completed' 'Host Resets' 'Errors'";
         String d3 = "'' 0.0 1.0 2.0 3.0 4.0 ";
         String d4 = "'Series1' 11.0 0.6 8.6 11.5 6.6 ";
         String d5 = "'Series2' 12.8 6.7 21.6 11.1 30.0 ";
         String data = d1 + d2 + d3 + d4 + d5;     
         public testing(){
              System.out.println(data);
              String[] result = data.split("\\s");
              for(int x=0;x<result.length;x++)
              System.out.println(result[x]);
         public static void main (String args[])throws IOException{
            testing Application = new testing();
    }ARRAY
    'Monitor
    Chart'
    2
    5
    'Total OverFlow'
    'Queued'
    'Completed'
    'Host Resets'
    'Errors'''
    0.0
    1.0
    2.0
    3.0
    4.0
    'Series1'
    11.0
    0.6
    8.6
    11.5
    6.6
    'Series2'
    12.8
    6.7
    21.6
    11.1
    30.0
    but how do i get the values out ??how do i noe it is which index or wad?
    11.0
    0.6
    8.6
    11.5
    6.6

  • Escape single quote from a String variable

    Hi,
    I have a String variable called "name" which i am using in my form tag.
    <form name=test action="test.jsp?fname=<%=name%>" method="post">
    But i am getting Javascript error if the "name" variable contains a string with some special characters like single quote( ' ).
    Plz help me to escape this special char from my String variable.
    Thanks..

    You need to url-encode the value using the URLEncoder class.
    http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html
    For example:
    <form name=test action="test.jsp?fname=<%=URLEncoder.encode(name, "ISO-8859-1")%>" method="post">

  • How do I make a Datagram Packet from a String?

    I am looking to make a Datagram Packet from a string. If I send a command to a server that allows remote connections via UDP, such as "restart" it will restart the server. I can accomplish this easily through the fput() method of PHP.
    I want a Java version of my utility, and am using the DatagramSocket and DatagramPacket classes. I see that I need to make a byte array and put it inside a DatagramPacket. How would I go about putting the string "restart" into a byte array?
    Thanks,

    Use the following code to send a Datagram:-
    import java.io.*;
    import java.net.*;
    // This class sends the specified text as a datagram to port 6010 of the
    // specified host.
    public class UDPSend {
        static final int port = 6010;
        public static void main(String args[]) throws Exception {
            if (args.length != 2) {
                System.out.println("Usage: java UDPSend <hostname> <message>");
                System.exit(0);
            // Get the internet address of the specified host
            InetAddress address = InetAddress.getByName(args[0]);
            // Convert the message to an array of bytes
            int msglen = args[1].length();
            byte[] message = new byte[msglen];
            args[1].getBytes(0, msglen, message, 0);
            // Initilize the packet with data and address
            DatagramPacket packet = new DatagramPacket(message, msglen,
                                   address, port);
            // Create a socket, and send the packet through it.
            DatagramSocket socket = new DatagramSocket();
            socket.send(packet);
    }This uses argments, if you want a string change the code accordingly.

Maybe you are looking for

  • How to add a border around a video (padding out to a larger size)?

    Hi, I'm having problems doing this in Quicktime Pro. I don't want to increase the size of the visible part of the video, just pad it out with black space. I created a gif file of the size I want and pasted it in, but rather than the video increasing

  • Facing issue when i try to open region in a dialog box

    013-04-04 01:59:39,198 [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR exception.EMRuntimeExceptionFilter logp.251 - javax.el.ELException: java.lang.NullPointerException javax.el.ELException: java.lang.NullPoint

  • "To Do's" not showing up on handheld.

    The To Do's I put into the desktop are not showing up on my handheld, neither can I figure out how to enter a new to do on the handheld. Post relates to: Centro (AT&T)

  • User equivalence check failed (RAC setup)

    Hello All, I am trying to set up user equivalence between 2 nodes, following instructions from "Oracle® Database Oracle Clusterware and Oracle Real Application Clusters Installation Guide 10g Release 2 (10.2) for Solaris Operating System (SPARC 64-Bi

  • Mouse position on screen

    is there any way to get the mouses position on the screen (not a window)? Stephen