Difference between revisions of "Spec 1.1 Errata"

From CMSC 420
(new part 1 errata page)
 
m (removed old note about error in jar file that has been fixed)
Line 89: Line 89:
 
</blockquote>
 
</blockquote>
 
If there is a distance tie, check the city names using java.lang.String.compareTo() (for a distance tie, the nearestCity name is less than the other city name).
 
If there is a distance tie, check the city names using java.lang.String.compareTo() (for a distance tie, the nearestCity name is less than the other city name).
 
== JAR file ==
 
InclusiveIntersectionVerifier.intersects(Line2D seg, Rectangle2D rect) does not work properly. This shouldn't be an issue for part 1.  A corrected JAR file will be made available for parts 2 and 3.
 

Revision as of 23:39, 7 February 2009

Using the provided XML processing code to get a working parser[edit]

Node -> Element[edit]

In the DOM, every XML object implements the org.w3c.dom.Node interface. Nodes have a lot of useful methods, but the ones you care most about are getNodeName(), getNodeValue(), and getAttribute(). Suppose you had a Node object representing one of our command elements. You could determine which command it was with the following code:

Node command = ...;
if (command.getNodeName().equals("createCity"))
// createCity command

To get the value of an attribute, you could use this code:

String name = command.getAttribute("name");

If you read the Java API, you'll see both Document and Element are subtypes of Node. A Node does not have the method getAttribute(). But Element does have a getAttribute() method.

Node Child List[edit]

To ignore comment nodes, you can even do an instanceof check of the command node to make sure it is of type Element.

instanceof checks can be costly. If there's an alternative, you should use it. That said, Node has a method called getNodeType().


Outputting XML using DOM[edit]

appendNode -> appendChild()[edit]

To append an Element to another Node:

results.appendNode(elt);

This should be

results.appendChild(elt);

Read the API.

Outputting XML Conventions[edit]

Error tag typo[edit]

General <error> Output

This is the form (in the exact output order) of a general <error> tag. The <parameters> tag will always be present even if there are no parameters to the command. In each command there may be several errors listed if several errors occur in a command you will only output the error of highest priority. For more information see XML Input specification for each command.

    		<error type="error1">
    		    <command name="name1"/>
    		    <parameters>
    		        <param1 value="value1"/>
    		        <param2 value="value2"/>
    		    </parameters>
    		<error/>

The last tag should be </error>, not <error/>.

Printing to System.out[edit]

It is sufficient to merely spit these out to System.out (the standard output stream) as they are discovered when processing the commands. However, remember that the result must be a well-formed XML document and a well-formed XML document must have a single root element.

Do not call System.out.println() to print out your output. Instead, create a new Document and append Elements to it as you process commands. You can print a Document to System.out using XmlUtility.print().

Output schema?[edit]

(You may want also to stick an <?xml version="1.0" ?> tag in the front (JAXP XML outputters will usually insert it in for you). So in other words, you don't need to worry about building a DOM object, since we'll expect you to just print it to the standard out anyway. We will test your output XML by feeding it into our XML parser, validating it against our schema, and then reprinting the DOM object we create, and diffing the results. After we standardize your output by building it into a DOM object and rewriting it to a stream, our XML and your XML should look exactly the same.

We do not have an output schema. Make sure that your output matches the spec requirements.

Drawing a spatial map using CanvasPlus[edit]

Color class[edit]

It should be noted that all colors used in CanvasPlus refer to their java.awt.Color counterparts.

Input[edit]

spatialWidth and spatialHeight[edit]

The attributes are spatialWidth and spatialHeight, both Unrestricted Integers...

spatialWidth and spatialHeight will always be 2k by 2k. That way you can take advantage of bit operators.

List cities[edit]

listCities Prints all cities (vertices) currently present in the graph.

Graph here means data dictionary.

Nearest City tie[edit]

nearestCity Will return the name and location of the closest city to the specified point in space. To do this correctly, you may want to use the PriorityQueue-otherwise, you might not be fast enough.

If there is a distance tie, check the city names using java.lang.String.compareTo() (for a distance tie, the nearestCity name is less than the other city name).