function Data = getJavaCustomData(JObj)
% This function is undocumented and will change in a future release

% Data=getJavaCustomData(JObj) retrieves the value stored with the Java
% object JObj using setJavaCustomData. If no data is stored it will return
% empty
%
%   Copyright 2010-2013 The MathWorks, Inc.


if isa(JObj,'java.lang.Object')
    % Get wrapper with callbackproperties
    hc = handle(JObj,'callbackproperties');
    if isempty(findprop(hc,'CustomData'))
        % Return empty if property does not exist
        Data = [];
    else
        Data = get(hc,'CustomData');
    end
else
    error(message('Controllib:general:UnexpectedError','First argument must be a Java object.'))
end