THE APPLICATION_CONTROLLER CLASS
import java.io.*;
import
java.util.*;
public class application_controller {
public static
void main(String [] args) {
servizio
s = new servizio();
composizione c =
new
composizione(
s.c_Nomefile1, s.c_Nomefile2, s.c_Nomefile );
}
}
THE SERVIZIO CLASS
import java.io.*;
import
java.util.*;
public class servizio {
public static String
c_Nomefile;
public static String c_Nomefile1;
public
static String c_Nomefile2;
public servizio()
{
c_Elenco();
c_Scelta();
}
static private void c_Elenco() {
System.out.println("ELENCO SERVIZI:");
String [] lista = new
File(".").list(); //crea
lista
for(int cx=0; cx<lista.length;
cx++)
if ( new File(lista[cx]).isFile()
) //verifica se Š
file
if (
lista[cx].toLowerCase().lastIndexOf(".owl") >= 0)
//e con estensione
.owl
System.out.print((" ţ
"+lista[cx]+"
").substring(0,20));
}
static private String input(String
prompt) {
String instr = "";
try
{
BufferedReader inp = new
BufferedReader(new
InputStreamReader(System.in));
do
{
System.out.print(prompt);
} while
((instr = inp.readLine()).length() == 0);
}
catch(Exception e){};
if (instr.lastIndexOf(".") < 0)
instr += ".owl";
return instr;
}
static
public void c_Scelta() {
c_Nomefile1 =
input("\nServizio principale : ");
c_Nomefile2 =
input("Servizio da comporre: ");
// crea nome file
composto
c_Nomefile =
c_Nomefile1.substring(0,c_Nomefile1.lastIndexOf(".")) +
c_Nomefile2;
}
}
THE COMPOSIZIONE CLASS
import java.io.*;
import
java.util.*;
public class composizione {
public static int
c_Comp;
// esito della composizione
public composizione (String file_1,
String file_2, String file_composto)
{
output out = new
output();
if ( (c_Comp = new
metodi_xml(file_2).c_ProceduraTag(file_1)) == 0)
{
out.c_EliminaFile();
out.c_ScriviMessaggio();
} else
{
System.out.println("\nFILE
COMPOSTO:\n");
out.c_StampaFile();
out.c_SpostaFile(file_1, file_2,
file_composto);
}
}
}
THE METODI_XML CLASS
import java.io.*;
import
java.util.*;
public class metodi_xml {
public static String
c_Tabella;
final private static String fileTMP =
"tmp.owl";
final private static xml_pars owl = new
xml_pars(); //classe parsing .XML
private static
String tempor;
private static String linea;
private static
boolean corretto;
public metodi_xml (String file)
{
System.out.print("Apro il file
"+file+" ... ");
if (! (corretto =
owl.load_parsing(file))
)
System.out.println("Errore!");
else
c_CompilaTabella(file);
}
public static void
c_CompilaTabella(String file) { // crea
tabella
System.out.println("Ok!\nCompilo la
tabella...");
owl.tag(2); //salta
header (tag <?> e tag
Ontology)
c_Tabella = tempor =
"";
while(true)
{
//String tag =
owl.ctags();
String tag =
owl.tags();
if (owl.nido < 0)
break;
tempor += tag;
c_AnalisiTag(tag);
if (linea.length() > 1) c_Tabella += linea +
"\n";
}
}
public
static int c_AnalisiTag(String tag)
{ // ritorna
tipo tag e linea
linea =
".";
if (owl.si_tag(tag,"<owls:")
> 0)
{
linea = owl.search_true(tag, "owls:Class ", "C")
+
owl.search_true(tag, "owls:ObjectProperty ", "P")
+
//owl.search_true(tag, "owls:Ontology ", "O")
+
linea;
if (linea.length() == 1)
{
System.out.println("Tag sconosciuto: " +
tag);
corretto = false;
};
linea += owl.search_tag(tag, "name=");
//"owls:name"
};
return
linea.charAt(0);
}
public static int c_ProceduraTag(String
file) { // esegue
utility
int comp=0; String temp =
"", tag = "";
System.out.print("Apro
il file "+file+" ... ");
if (!
owl.load_parsing(file) )
{
System.out.println("Errore!");
corretto = false; };
if (corretto)
{
System.out.println("Ok!\nAvvio
utility...");
owl.tag(2); //salta header (tag <?> e tag
Ontology)
do
{
tag = owl.tags(); //o tag =
owl.tag(0);
int tipo =
c_AnalisiTag(tag);
if (linea.length() > 1)
{
if (c_Tabella.indexOf(linea) < 0)
{
//temp +=
owl.ctag_root(owl.xml_id);
temp +=
owl.tag_root(owl.xml_id);
} else
{
if (tipo == 'C') comp = 1;
//...
}
}
} while (owl.nido >= 0);
};
if (!corretto) {
System.out.println("Utility interrotta per errori."); comp = 0;
};
// if (temp.length() > 0)
{ //aggiunge
intestazione
padre
owl.reset(); tempor = owl.tags() + owl.tags()
+
tempor + temp + tag; //}; //temp + tempor + tag;
//};
owl.save_pars(fileTMP,
tempor); //crea file
temporaneo
return
comp;
}
}
THE OUTPUT CLASS
import java.io.*;
import
java.util.*;
public class output {
final private static String
fileTMP = "tmp.owl";
final private static String cartellaServizi =
"servizi";
final private static xml_pars owl = new xml_pars(2,8);
//classe parsing .XML
private static void waitkey() {
try
{
System.out.print("\nPremere INVIO
per proseguire...");
System.in.read(); System.out.println();
}
catch(Exception e) {}
}
public static void
c_SpostaFile(String file_1, String file_2, String file_composto)
{
owl.newdir(cartellaServizi); //se non
c'Š crea la
cartella
//new
File(cartellaServizi).mkdirs(); new File(fileTMP).renameTo(new
File(cartellaServizi + "/" +
file_composto));
if
(owl.load_parsing(fileTMP))
{
owl.save_parsing(cartellaServizi + "/" + file_composto);
c_EliminaFile();
owl.load_parsing(file_1); owl.save_parsing(cartellaServizi + "/" +
file_1);
owl.load_parsing(file_2); owl.save_parsing(cartellaServizi + "/" +
file_2);
}
}
public static void c_StampaFile() {
int cx=0;
if
(owl.load_parsing(fileTMP))
do
{ System.out.print(owl.ctags()); if ( ((++cx)&15) == 0)
waitkey();
} while (owl.nido >= 0
|| cx<3);
}
public static void c_EliminaFile()
{
owl.delfile(fileTMP); //new
File(fileTMP).delete();
}
public static void
c_ScriviMessaggio() {
System.out.println("\nI due servizi non sono tra loro
componibili.");
waitkey();
}
}
How can I create the .dd file and the application file to transform
this software in a web service? Thanks for the help and excuse for the
lenght of the message