FileDocCategorySizeDatePackage
ValidationTest2.javaAPI DocExample1384Sun Jul 07 09:50:12 BST 2002javajaxb

ValidationTest2

public class ValidationTest2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        if (args.length != 1) {
            System.out.println("Usage: java javajaxb.ValidationTest2 " +
                "[XML movie database filename]");
            return;
        }

        try {
            File xmlFile = new File(args[0]);
            FileInputStream inputStream = new FileInputStream(xmlFile);

            // Read in movies database
            Movies movies = Movies.unmarshal(inputStream);

            /* ******* SETTING INVALID DATA *********** */
            List movieList = movies.getMovie();
            Movie movie = (Movie)movieList.get(0);
            Cast cast = movie.getCast();
            List actorList = cast.getActor();
            Actor actor = (Actor)actorList.get(0);
            actor.setHeadliner("illegalValue");

            // Create output stream
            File file = new File("output.xml");
            FileOutputStream outputStream = new FileOutputStream(file);

            // Marshal back out
            movies.marshal(outputStream);
        } catch (Exception e) {
            e.printStackTrace();
        }