Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6958931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:12:18+00:00 2026-05-27T15:12:18+00:00

My challenge is this… I’m getting a string path (e.g x1/x2/x3/Xn, Xn/x2/x3, etc.) (e.g

  • 0

My challenge is this… I’m getting a string path (e.g x1/x2/x3/Xn, Xn/x2/x3, etc.) (e.g String path = Project.getName() ). So basically, I can have any type of path (any level and any depth). I’m trying to find a way to convert this to a data structure so I can implement it in my gwt CellTree. So far, I have implemented the CellTree from this example GWT Cell tree, how to use? .

Since, I have no idea of the level or the depth, I am a bit lost… I think I should go with a recursive function which split my string path then add them, but check if they already existe, etc…

I also looked over this question Construct a tree structure from list of string paths. But I’m kind of new to java and design patterns, so any pointers or bits of code (example) would help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:12:18+00:00Added an answer on May 27, 2026 at 3:12 pm
        String fullPath = mystringpath;
        String[] paths = fullPath.split("/");
        String combinedPaths = "";
        Node current = this.root;
    
        // We will never process the last node since it could be a repository
        // or a wildcard. The last step of this process would be doing that.
        for (int i = 0; i < paths.length - 1; i++) {
            combinedPaths += "/" + paths[i];
            if (this.collected.containsKey(combinedPaths)) {
                current = this.collected.get(combinedPaths);
            }
            else {
                String name = paths[i];
                Node childItem = new Node(name);
                current.addItem(childItem);
                current = childItem;
                this.collected.put(combinedPaths, current);
            }
        }
    
        // Process the last node since it represents the repository name.
            String name = paths[paths.length - 1];
            Node leafItem = new Node(name);
            combinedPaths += "/" + name;
            current.addItem(leafItem);
            current = leafItem;
            this.collected.put(combinedPaths, current);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Challenge: I have this code that fails to compile. Can you figure out what's
I Have a Challenge like this, Dictionary<string,Dictionary<string,int>> dic=new Dictionary<string,Dictionary<string,int>>(); i want them into a
Hopefully someone here can help me with this challenge! I have a parent page
I have a simple challenge with a background not animating. I have used this
This next challenge of mine involves jqtransform which can be found here http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/ I
I have this new challenge to load ~100M rows from an Oracle database and
I'm looking for an HTML/CSS solution to this challenge: I have multiple elements with
I have a similar challenge to this post: Batch insert/update with entity framework from
I'm learning MVC and faced this challenge which I can't figure out how. When
I have web service secured with SPNego (HTTP challenge returns WWW-Authenticate: Negotiate). This security

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.