Example #1
0
		public static void  appendVariableValue(System.Text.StringBuilder sb, Value val)
		{
			appendVariableValue(sb, val, "");
		} //$NON-NLS-1$
Example #2
0
		} //$NON-NLS-1$
		
		public static void  appendVariableValue(System.Text.StringBuilder sb, Value val, String variableName)
		{
			int type = val.getType();
			String typeName = val.getTypeName();
			String className = val.getClassName();
			
			// if no string or empty then typeName is blank
			if (typeName != null && typeName.Length == 0)
				typeName = null;
			
			switch (type)
			{
				
				case VariableType.NUMBER: 
				{
					double value = ((Double) val.ValueAsObject);
					long longValue = (long) value;
					// The value is stored as a double; however, in practice most values are
					// actually integers.  Check to see if this is the case, and if it is,
					// then display it:
					//    - without a fraction, and
					//    - with its hex equivalent in parentheses.
					// Note, we use 'long' instead of 'int', in order to deal with the
					// ActionScript type 'uint'.
					if (longValue == value)
					{
						sb.Append(longValue);
						sb.Append(" (0x"); //$NON-NLS-1$
						sb.Append(Convert.ToString(longValue, 16));
						sb.Append(")"); //$NON-NLS-1$
					}
					else
					{
						sb.Append(value);
					}
					break;
				}
				
				
				case VariableType.BOOLEAN: 
				{
					Boolean b = (Boolean) val.ValueAsObject;
					if (b)
						sb.Append("true");
					//$NON-NLS-1$
					else
						sb.Append("false"); //$NON-NLS-1$
					break;
				}
				
				
				case VariableType.STRING: 
				{
					bool isException = (val.isAttributeSet(ValueAttribute.IS_EXCEPTION));
					sb.Append(isException?'<':'\"');
					sb.Append(val.ValueAsString);
					sb.Append(isException?'>':'\"');
					break;
				}
				
				
				case VariableType.OBJECT: 
				{
					sb.Append("["); //$NON-NLS-1$
					sb.Append(className);
					
					// Normally, we include the object id after the class name.
					// However, when running fdbunit, don't show object IDs, so that
					// results can reproduce consistently from one run to the next.
					if (SystemProperties.getProperty("fdbunit") == null)
					//$NON-NLS-1$
					{
						sb.Append(" "); //$NON-NLS-1$
						sb.Append(val.ValueAsObject); // object id
					}
					if (typeName != null && !typeName.Equals(className))
					{
						sb.Append(", class='"); //$NON-NLS-1$
						
						// Often the typename is of the form 'classname@hexaddress',
						// but the hex address is the same as the object id which
						// is returned by getValue() -- we don't want to display it
						// here.
						int at = typeName.IndexOf('@');
						if (at != - 1)
							typeName = typeName.Substring(0, (at) - (0));
						
						sb.Append(typeName);
						sb.Append('\'');
					}
					sb.Append(']');
					break;
				}
				
				
				case VariableType.FUNCTION: 
				{
					// here we have a special case for getters/setters which 
					// look like functions to us, except the attribute is set.
					sb.Append('[');
					if (val.isAttributeSet(VariableAttribute.HAS_GETTER))
						sb.Append(LocalizationManager.getLocalizedTextString("getterFunction"));
					//$NON-NLS-1$
					else if (val.isAttributeSet(VariableAttribute.HAS_SETTER))
						sb.Append(LocalizationManager.getLocalizedTextString("setterFunction"));
					//$NON-NLS-1$
					else
						sb.Append(LocalizationManager.getLocalizedTextString("function")); //$NON-NLS-1$
					sb.Append(' ');
					
					sb.Append(val.ValueAsObject);
					if (typeName != null && !typeName.Equals(variableName))
					{
						sb.Append(", name='"); //$NON-NLS-1$
						sb.Append(typeName);
						sb.Append('\'');
					}
					sb.Append(']');
					break;
				}
				
				
				case VariableType.MOVIECLIP: 
				{
					sb.Append("["); //$NON-NLS-1$
					sb.Append(className);
					sb.Append(" "); //$NON-NLS-1$
					sb.Append(val.ValueAsObject);
					if (typeName != null && !typeName.Equals(className))
					{
						sb.Append(", named='"); //$NON-NLS-1$
						sb.Append(typeName);
						sb.Append('\'');
					}
					sb.Append(']');
					break;
				}
				
				
				case VariableType.NULL: 
				{
					sb.Append("null"); //$NON-NLS-1$
					break;
				}
				
				
				case VariableType.UNDEFINED: 
				{
					sb.Append("undefined"); //$NON-NLS-1$
					break;
				}
				
				
				case VariableType.UNKNOWN: 
				{
					sb.Append(LocalizationManager.getLocalizedTextString("unknownVariableType")); //$NON-NLS-1$
					break;
				}
				}
		}
Example #3
0
		/// <summary> Traverse the given variables dumping any Movieclips we find that
		/// contain a member called 'member'
		/// </summary>
		/// <throws>  NotConnectedException  </throws>
		/// <throws>  NoResponseException  </throws>
		/// <throws>  NotSuspendedException  </throws>
		internal virtual void  dumpTree(System.Collections.IDictionary tree, System.Collections.IList e, String name, Value result, String member)
		{
			// name for this variable
			if (name == null)
				name = ""; //$NON-NLS-1$
			
			// have we seen it already
			if (tree.Contains(result))
				return ;
			
			tree[result] = name; // place it
			
			// first iterate over our members looking for 'member'
			Value proto = result;
			bool done = false;
			while (!done && proto != null)
			{
				Variable[] members = proto.getMembers(m_session);
				proto = null;
				
				// see if we find one called 'member'
				for (int i = 0; i < members.Length; i++)
				{
					Variable m = members[i];
					String memName = m.getName();
					if (memName.Equals(member) && !tree.Contains(m))
					{
						e.Add(name);
						e.Add(result);
						e.Add(m);
						tree[m] = name + "." + memName; //$NON-NLS-1$
						done = true;
					}
					else if (memName.Equals("__proto__"))
					//$NON-NLS-1$
						proto = members[i].getValue();
				}
			}
			
			// now traverse other mcs recursively
			done = false;
			proto = result;
			while (!done && proto != null)
			{
				Variable[] members = proto.getMembers(m_session);
				proto = null;
				
				// see if we find an mc
				for (int i = 0; i < members.Length; i++)
				{
					Variable m = members[i];
					String memName = m.getName();
					
					// if our type is NOT object or movieclip then we are done
					if (m.getValue().getType() != VariableType.OBJECT && m.getValue().getType() != VariableType.MOVIECLIP)
					{
					}
					else if (m.getValue().Id != Value.UNKNOWN_ID)
						dumpTree(tree, e, name, m.getValue(), member);
					else if (memName.Equals("__proto__"))
					//$NON-NLS-1$
					{
						proto = m.getValue();
						//					name = name + ".__proto__";
					}
				}
			}
		}