trex12

groups

Discussion created by trex12 on Aug 20, 2010
hi,

i got a problem with loop, because i need make it reverse.. can anybody help me?

this is my code:


public class interpolacia {


public static void main(String[] args) {

ServerInitializer serverInitializer = null;
ServerConnection connection = null;


try
{

serverInitializer = new ServerInitializer();
serverInitializer.initializeServer("esprit", "misa", "a");

connection = new ServerConnection();
connection.connect("michalavirtual");
IServerObjectManager som = connection.getServerObjectManager();
IServerContext context = som.createServerContext("nova", "MapServer");

MapServer ms = (MapServer)context.getServerObject();
String nazov = ms.getDefaultMapName();

MapServerInfo mapinfo = (MapServerInfo)ms.getServerInfo(nazov);
IMapLayerInfos maplayerinfo = mapinfo.getMapLayerInfos();

for (int i = 0; i < maplayerinfo.getCount(); i++)
{
if (maplayerinfo.getElement(i).getSubLayers() == null)
{
int m = i;

do {

m = maplayerinfo.getElement(m).getParentLayerID();
System.out.println("<"+maplayerinfo.getElement(m). getName()+">");
}

while (maplayerinfo.getElement(m).getParentLayerID() != -1);

System.out.println(maplayerinfo.getElement(i).getN ame());

}
}



}
catch (AutomationException ae)
{
System.err.println("Caught AutomationException: " + ae.getMessage() + "\n");
ae.printStackTrace();
}

catch (IOException e)
{
System.err.println("Caught IOException: " + e.getMessage() + "\n");
e.printStackTrace();
}
}

}


the result of this is:

<pod-podgrupa>
<podgrupa1>
<grupa1>
Banska_Bystrica
<pod-pod-pod-podgrupa>
<pod-pod-podgrupa>
<pod-podgrupa>
<podgrupa1>
<grupa1>
KOTY
<pod-pod-pod-podgrupa>
<pod-pod-podgrupa>
<pod-podgrupa>
<podgrupa1>
<grupa1>
Riecna_siet_Clip
<grupa1>
Riecna_siet
<grupa2>
Banska_Bystrica_Select
<pogrupa2>
<grupa2>
katastralne_uzemie

i need make it reverse like:

<grupa1>
<podgrupa1>
<pod-podgrupa>
Banska_Bystrica
<grupa1>
<podgrupa1>
<pod-podgrupa>
<pod-pod-podgrupa>
<pod-pod-pod-podgrupa>
KOTY
...

Outcomes