All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dottydingo.hyperion.jpa.persistence.PathIterator Maven / Gradle / Ivy

The newest version!
package com.dottydingo.hyperion.jpa.persistence;

import java.util.Iterator;

/**
 */
public class PathIterator implements Iterator
{
    private String[] pathParts;
    int index = 0;

    public PathIterator(String path)
    {
        if(path == null || path.length() == 0)
            pathParts = new String[0];
        else
            pathParts = path.split("\\.");
    }

    @Override
    public boolean hasNext()
    {
        return index < pathParts.length;
    }

    @Override
    public String next()
    {
        if(index >= pathParts.length)
            throw new IndexOutOfBoundsException("Iterated past end.");

        return pathParts[index++];
    }

    @Override
    public void remove()
    {

    }

    public static PathIterator getPath(String path)
    {
        return new PathIterator(path);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy