AMConverter.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) AMConverter.java 1.63 - last change made 06/25/97
*/
/**
* This class can convert attribute managment trees to strings and
* such strings back again to attribute management trees. The string
* produced is a complete description of an application, and so it can
* be used to save a tree to a file.
*
* @see AttributeManager
* @version 1.63, 06/25/97
*/
public class AMConverter extends Converter {
private static AttributeListConverter attrlistconv =
new AttributeListConverter();
public AMConverter() {
}
/**
* List of paths (package prefixes) to groups of Shadow classes
* also a few individual Shadow classes. The Hashtables are for
* caching the matches after they are discovered.
*/
/**
* Caches the matches after they are discovered.
*/
}
/**
* Adds the name of a package where custom shadow
* classes can be found.
* Package names in this list always end with a "."
*/
else
}
/**
* Adds a specific shadow class to the list.
* Specific shadow classes
* in the list never end with a "."
*/
}
static {
// add packages where shadow classes might be found
//
// Don't add any more of these or the quick
// code generation will
// be screwed!
// add individual exceptions
(/* NOI18N */"sunsoft.jws.visual.rt.base.Root");
}
/**
* Figures out the short name for a shadow class. Removes the
* initial component of a class name if it's one of the currently
* listed paths for finding shadow classes. The result is the
* abbreviated name for the shadow class that can be placed in the
* save file.
*
* Warning: you should not nest shadow packages in the path within
* each other, as this routine might return the wrong shortened
* form
* of the class name.
*/
// return the cached value if available
/* JSTYLED */
if (longClassName.startsWith(s))
}
// the long class name was not found in any of the paths
return (longClassName);
}
/**
* Searches the currently listed shadow paths for the shadow class
* given. Returns a runtime class reference to the shadow class
* once it finds that class under one of the paths (or, in the end,
* under the actual name given.)
*
* This is basically the reverse of shortenShadowPath.
*/
// return the cached value if available
try {
(shortClassName)));
}
catch (ClassNotFoundException ex) {
// that didn't work, silently try something else...
}
}
/* JSTYLED */
try {
(path + shortClassName);
break;
}
catch (ClassNotFoundException ex) {
// that didn't work, silently try again...
}
}
try {
}
catch (ClassNotFoundException ex) {
// that didn't work either, how sad
("sunsoft.jws.visual.rt.type.AMConverter.FMT.0",
}
}
// cache this pairing so it won't have to be looked up again
return (retval);
}
/**
* Creates a string from the reference to the root or branch of the
* attribute management tree given. Appends the string to the given
* string buffer.
*
* @param obj attribute management tree reference
* @param buf string buffer to append to
* @return string that describes the tree
*/
return;
// Make sure the first card is showing before saving the card panel.
if (obj instanceof CardPanelShadow) {
}
//
// Skip over any windows that are marked as panels.
//
/* JSTYLED */
return;
}
// this object's own attributes
incrIndent();
decrIndent();
// children
if (tree instanceof AMContainer) {
if (e.hasMoreElements()) {
incrIndent();
incrIndent();
while (e.hasMoreElements()) {
}
decrIndent();
decrIndent();
}
}
}
/**
* Call the convertFromString function that takes a version number
* instead. Tree conversion cannot take place without a version
* number (for the string description.)
*
* @exception Error when an attempt is made to call this method
*/
/* JSTYLED */
"sunsoft.jws.visual.rt.type.AMConverter.AMConverter__convertF.0"));
}
/**
* Creates a new tree based upon the description string given.
* There should only be one object (as the root of the tree) in the
* string. That root object may contain other objects, or children,
* as it were.
*
* @param version the version number for the gui description string
* @param s the string to convert to a tree @return new shadow tree
* @exception ParseException when there is an error in the string
*/
if (s == null)
return null;
// Parse the string
try {
}
catch (NoSuchElementException ex) {
/* BEGIN JSTYLED */
/* END JSTYLED */
}
// Start recording AMRef's made during construction of tree
// Create the attribute manager
return null;
// Parse the attributes and children
// Stop recording and resolve all AMRef's that were made
return mgr;
}
// Instantiate a new attribute manager
if (onLineType == null)
return null;
try {
}
catch (IllegalAccessException e) {
/* BEGIN JSTYLED */
throw new ParseException(Global.fmtMsg("sunsoft.jws.visual.rt.type.AMConverter.FMT.1", Global.getMsg("sunsoft.jws.visual.rt.type.AMConverter.Could__not__access__"), onLineType.getName()));
/* END JSTYLED */
}
catch (InstantiationException e) {
/* BEGIN JSTYLED */
throw new ParseException(Global.fmtMsg("sunsoft.jws.visual.rt.type.AMConverter.FMT.2", Global.getMsg("sunsoft.jws.visual.rt.type.AMConverter.Could__not__instantiat.2"), onLineType.getName()));
/* END JSTYLED */
}
// Assign name of shadow object
}
return mgr;
}
private void convertChildren(double version,
return;
while (e.hasMoreElements()) {
try {
}
catch (NoSuchElementException ex) {
/* BEGIN JSTYLED */
/* END JSTYLED */
}
continue;
//
// Insert a frame around any panels that are
// immediate children
// of the root, and mark the frame as a panel.
//
(child instanceof PanelShadow)) {
FrameShadow f = new FrameShadow();
f.isPanel(true);
} else {
// REMIND: add error check for non-AMContainer type
}
}
}
/**
* The conversion of shadow trees into code is performed within the
* designer and not implemented here. This method should never be
* called.
*
* @exception Error when an attempt is made to call this method
*/
/* BEGIN JSTYLED */
throw new Error(Global.fmtMsg("sunsoft.jws.visual.rt.type.AMConverter.FMT.3", Global.getMsg("sunsoft.jws.visual.rt.type.AMConverter.will__not__generate__co.4"),
/* END JSTYLED */
}
}