× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: HTML to XML, vice versa
  • From: "Stone, Brad V (TC)" <bvstone@xxxxxxxxxxxxxx>
  • Date: Thu, 15 Mar 2001 08:53:54 -0600

Joe, 

This has made the most sense yet. 

So, here's what I have so far.  Let me know if I'm on the right track:

public class FieldDefinition extends java.lang.Object
{
  protected String name = null;
  protected String xmlTag = null;
  protected String htmlClass = null;

  public FieldDefinition(String name)
  {
    this(name, "", "");
  }

  public FieldDefinition(String name, String xmlTag, String htmlClass)
  {
    this.name = name;
    this.xmlTag = xmlTag;
    this.htmlClass = htmlClass;
  }
}

public class FieldData extends java.lang.Object
{
  protected String data = null;

  public FieldData(String data)
  {
    this.data = data;
  }

}

public class FieldFormatter extends java.lang.Object
{

  public String toXML(FieldDefinition definition, FieldData data)
  {
    return ("<" + definition.xmlTag + ">" + data + "<" + definition.xmlTag +
"/>");
  }

  public String toTD(FieldDefinition definition, FieldData data)
  {

    if (definition.htmlClass.equals(""))
      return ("<td>" + data + "</td>");
    else
      return ("<td class=" + definition.htmlClass + ">" + data + "</td>");
  }

}

To me, it seems I could combine the FieldDefinition and FieldData classes
since I plan on having all the attributes dynamic.  Either that or I've put
the wrong things in FieldDefinition.  Actually, just thinking about it that
is what I should have done I'm sure.

I just can't think of any examples of "static" field definitions to put in
the FieldDefinition class.

I dunno... whatcha think?  (anyone, as well as Joe.)

Brad

> -----Original Message-----
> From: Joe Pluta [mailto:joepluta@plutabrothers.com]
> Sent: Wednesday, March 14, 2001 9:09 AM
> To: JAVA400-L@midrange.com
> Subject: RE: HTML to XML, vice versa
> 
> 
> Brad, in line with my previous post, you basically need three classes:
> 
> FieldDefinition (which defines the static characteristics of 
> the field)
> 
> FieldData (which holds the actual data object and any runtime 
> attribues)
> 
> FieldFormatter (which takes a FieldDefinition and a FieldData 
> object, and returns the appropriate representation)
> 
> You do NOT create a separate decorator for each field type; 
> you instead make your FieldDefinition very flexible and your 
> FieldFormatter very smart.
> 
> Joe
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.