blob: ddfe31cb0cf33c95758f938834434bc581a21632 (
plain)
1
|
/*
Action script 2.0 RSS parser package
Copyright (C) 2006 Cybozu Labs, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
class: com.cybozuLab.rssParser.Utils
modified: 20/Jan/2006
Utilities for RSS parser package.
*/
class com.cybozuLab.rssParser.Utils
{
private static var INTEND_SPACE_NUMBER:Number = 3;
static public function traceObj( targetObj:Object, hierarchyLevel:Number ):Void
{
if( hierarchyLevel == undefined )
{
hierarchyLevel = 0;
}
for( var prop in targetObj )
{
if( typeof( targetObj[prop] ) != "object" )
{
trace( makeIntendSpace( hierarchyLevel ) + prop + " : " + targetObj[prop] );
}
else
{
trace( makeIntendSpace( hierarchyLevel ) + prop );
hierarchyLevel++;
traceObj( targetObj[prop], hierarchyLevel );
hierarchyLevel--;
}
}
}
static public function objToString( targetObj:Object, hierarchyLevel:Number ):String
{
var resultStr:String = "";
if( hierarchyLevel == undefined )
{
hierarchyLevel = 0;
}
for( var prop in targetObj )
{
if( typeof( targetObj[prop] ) != "object" )
{
resultStr += makeIntendSpace( hierarchyLevel ) + prop + " : " + targetObj[prop] + "\n";
}
else
{
resultStr += makeIntendSpace( hierarchyLevel ) + prop + "\n";
hierarchyLevel++;
resultStr += objToString( targetObj[prop], hierarchyLevel );
hierarchyLevel--;
}
}
return resultStr;
}
static private function makeIntendSpace( hierarchyLevel:Number ):String
{
var resultString:String = "";
for( var i:Number=0; i < INTEND_SPACE_NUMBER * hierarchyLevel; i++ )
{
resultString += " ";
}
return resultString+"|-";
}
static public function countProperty( targetObj:Object ):Number
{
var i:Number = 0;
for( var prop in targetObj ) { i++; }
return i;
}
}
|