📄 downloadmanagerstateimpl.java
字号:
public File getFileLink(File link_source)
{
return getFileLinks().get(link_source);
}
public CaseSensitiveFileMap getFileLinks()
{
List values = getListAttributeSupport("filelinks");
CaseSensitiveFileMap res = new CaseSensitiveFileMap();
for (int i = 0; i < values.size(); i++)
{
String entry = (String)values.get(i);
int sep = entry.indexOf("\n");
if (sep != -1)
{
File target = sep != entry.length() - 1 ? new File(entry.substring(sep + 1)) : null;
res.put(new File(entry.substring(0, sep)), target);
}
}
return res;
}
public boolean isOurContent()
{
Map mapAttr = getMapAttribute("Plugin.azdirector.ContentMap");
return mapAttr != null && mapAttr.containsKey("DIRECTOR PUBLISH");
}
protected String getStringAttribute(String attribute_name)
{
informWillRead(attribute_name);
String s;
this_mon.enter();
if (attributes.get(attribute_name) instanceof byte[])
break MISSING_BLOCK_LABEL_39;
s = null;
this_mon.exit();
return s;
byte bytes[];
String s1;
bytes = (byte[])(byte[])attributes.get(attribute_name);
if (bytes != null)
break MISSING_BLOCK_LABEL_71;
s1 = null;
this_mon.exit();
return s1;
s1 = new String(bytes, "UTF8");
this_mon.exit();
return s1;
UnsupportedEncodingException e;
e;
String s2;
Debug.printStackTrace(e);
s2 = null;
this_mon.exit();
return s2;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
protected void setStringAttribute(String attribute_name, String attribute_value)
{
boolean changed = false;
this_mon.enter();
if (attribute_value == null)
{
if (attributes.containsKey(attribute_name))
{
attributes.remove(attribute_name);
changed = true;
}
} else
{
try
{
byte existing_bytes[] = (byte[])(byte[])attributes.get(attribute_name);
byte new_bytes[] = attribute_value.getBytes("UTF8");
if (existing_bytes == null || !Arrays.equals(existing_bytes, new_bytes))
{
attributes.put(attribute_name, new_bytes);
changed = true;
}
}
catch (UnsupportedEncodingException e)
{
Debug.printStackTrace(e);
}
}
this_mon.exit();
break MISSING_BLOCK_LABEL_131;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (changed)
{
write_required = true;
informWritten(attribute_name);
}
return;
}
public long getLongAttribute(String attribute_name)
{
informWillRead(attribute_name);
Long l;
Object def;
long l2;
this_mon.enter();
l = (Long)attributes.get(attribute_name);
if (l != null)
break MISSING_BLOCK_LABEL_132;
def = default_attributes.get(attribute_name);
if (def == null)
break MISSING_BLOCK_LABEL_119;
if (!(def instanceof Long))
break MISSING_BLOCK_LABEL_70;
l2 = ((Long)def).longValue();
this_mon.exit();
return l2;
if (!(def instanceof Integer))
break MISSING_BLOCK_LABEL_96;
l2 = ((Integer)def).longValue();
this_mon.exit();
return l2;
Debug.out((new StringBuilder()).append("unknown default type ").append(def).toString());
l2 = 0L;
this_mon.exit();
return l2;
long l1 = l.longValue();
this_mon.exit();
return l1;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void setLongAttribute(String attribute_name, long attribute_value)
{
boolean changed = false;
this_mon.enter();
Long existing_value = (Long)attributes.get(attribute_name);
if (existing_value == null || existing_value.longValue() != attribute_value)
{
attributes.put(attribute_name, new Long(attribute_value));
changed = true;
}
this_mon.exit();
break MISSING_BLOCK_LABEL_84;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (changed)
{
write_required = true;
informWritten(attribute_name);
}
return;
}
public void setListAttribute(String name, String values[])
{
List list = values != null ? Arrays.asList((Object[])(Object[])values.clone()) : null;
setListAttribute(name, list);
}
public String getListAttribute(String name, int idx)
{
if (name.equals("networks") || name.equals("peersources"))
throw new UnsupportedOperationException("not supported right now, implement it yourself :P");
informWillRead(name);
List values;
Object o;
this_mon.enter();
values = (List)attributes.get(name);
if (values != null && idx < values.size() && idx >= 0)
break MISSING_BLOCK_LABEL_86;
o = null;
this_mon.exit();
return ((String) (o));
String s2;
o = values.get(idx);
if (!(o instanceof byte[]))
break MISSING_BLOCK_LABEL_172;
byte bytes[] = (byte[])(byte[])o;
String s = null;
try
{
s = StringInterner.intern(new String(bytes, "UTF8"));
}
catch (UnsupportedEncodingException e)
{
Debug.printStackTrace(e);
}
if (s != null)
values.set(idx, s);
s2 = s;
this_mon.exit();
return s2;
String s1;
if (!(o instanceof String))
break MISSING_BLOCK_LABEL_197;
s1 = (String)o;
this_mon.exit();
return s1;
this_mon.exit();
break MISSING_BLOCK_LABEL_219;
Exception exception;
exception;
this_mon.exit();
throw exception;
return null;
}
public String[] getListAttribute(String attribute_name)
{
if (attribute_name == "networks")
return getNetworks();
if (attribute_name == "peersources")
return getPeerSources();
List l = getListAttributeSupport(attribute_name);
if (l == null)
return null;
String res[] = new String[l.size()];
try
{
res = (String[])(String[])l.toArray(res);
}
catch (ArrayStoreException e)
{
Debug.out((new StringBuilder()).append("getListAttribute( ").append(attribute_name).append(") - object isnt String - ").append(e).toString());
return null;
}
return res;
}
protected List getListAttributeSupport(String attribute_name)
{
informWillRead(attribute_name);
List list;
this_mon.enter();
List values = (List)attributes.get(attribute_name);
List res = new ArrayList(values == null ? 0 : values.size());
if (values != null)
{
for (int i = 0; i < values.size(); i++)
{
Object o = values.get(i);
if (o instanceof byte[])
{
byte bytes[] = (byte[])(byte[])o;
String s = null;
try
{
s = StringInterner.intern(new String(bytes, "UTF8"));
}
catch (UnsupportedEncodingException e)
{
Debug.printStackTrace(e);
}
if (s != null)
{
res.add(s);
values.set(i, s);
}
continue;
}
if (o instanceof String)
res.add(o);
}
}
list = res;
this_mon.exit();
return list;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
protected void setListAttribute(String attribute_name, List attribute_value)
{
boolean changed = false;
this_mon.enter();
if (attribute_value == null)
{
if (attributes.containsKey(attribute_name))
{
attributes.remove(attribute_name);
changed = true;
}
} else
{
List old_value = getListAttributeSupport(attribute_name);
if (old_value == null || old_value.size() != attribute_value.size())
{
attributes.put(attribute_name, attribute_value);
changed = true;
} else
{
if (old_value == attribute_value)
Debug.out("setListAttribute: should clone?");
changed = !BEncoder.listsAreIdentical(old_value, attribute_value);
if (changed)
attributes.put(attribute_name, attribute_value);
}
}
this_mon.exit();
break MISSING_BLOCK_LABEL_152;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (changed)
{
write_required = true;
informWritten(attribute_name);
}
return;
}
public Map getMapAttribute(String attribute_name)
{
informWillRead(attribute_name);
Map map;
this_mon.enter();
Map value = (Map)attributes.get(attribute_name);
map = value;
this_mon.exit();
return map;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void setMapAttribute(String attribute_name, Map attribute_value)
{
setMapAttribute(attribute_name, attribute_value, false);
}
protected void setMapAttribute(String attribute_name, Map attribute_value, boolean disable_change_notification)
{
boolean changed = false;
this_mon.enter();
if (attribute_value == null)
{
if (attributes.containsKey(attribute_name))
{
attributes.remove(attribute_name);
changed = true;
}
} else
{
Map old_value = getMapAttribute(attribute_name);
if (old_value == null || old_value.size() != attribute_value.size())
{
attributes.put(attribute_name, attribute_value);
changed = true;
} else
{
if (old_value == attribute_value)
Debug.out("setMapAttribute: should clone?");
changed = !BEncoder.mapsAreIdentical(old_value, attribute_value);
if (changed)
attributes.put(attribute_name, attribute_value);
}
}
this_mon.exit();
break MISSING_BLOCK_LABEL_157;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (changed && !disable_change_notification)
{
write_required = true;
informWritten(attribute_name);
}
return;
}
public boolean hasAttribute(String name)
{
boolean flag;
this_mon.enter();
if (attributes != null)
break MISSING_BLOCK_LABEL_25;
flag = false;
this_mon.exit();
return flag;
flag = attributes.containsKey(name);
this_mon.exit();
return flag;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void setIntAttribute(String name, int value)
{
setLongAttribute(name, value);
}
public int getIntAttribute(String name)
{
return (int)getLongAttribute(name);
}
public void setBooleanAttribute(String name, boolean value)
{
setLongAttribute(name, value ? 1 : 0);
}
public boolean getBooleanAttribute(String name)
{
return getLongAttribute(name) != 0L;
}
public static DownloadManagerState getDownloadState(DownloadManager dm)
{
return new nullState(dm);
}
protected void informWritten(final String attribute_name)
{
List listeners_ref = listeners_cow.getList();
for (int i = 0; i < listeners_ref.size(); i++)
try
{
((DownloadManagerStateListener)listeners_ref.get(i)).stateChanged(this, new DownloadManagerStateEvent() {
final String val$attribute_name;
final DownloadManagerStateImpl this$0;
public int getType()
{
return 1;
}
public Object getData()
{
return attribute_name;
}
{
this$0 = DownloadManagerStateImpl.this;
attribute_name = s;
super();
}
});
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
listeners_ref = null;
CopyOnWriteList write_listeners = (CopyOnWriteList)listeners_write_map_cow.get(attribute_name);
if (write_listeners != null)
listeners_ref = write_listeners.getList();
if (listeners_ref != null)
{
for (int i = 0; i < listeners_ref.size(); i++)
try
{
((DownloadManagerStateAttributeListener)listeners_ref.get(i)).attributeEventOccurred(download_manager, attribute_name, 1);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
}
protected void informWillRead(final String attribute_name)
{
List will_be_read_list;
will_be_read_list = (List)tls_wbr.get();
if (will_be_read_list.contains(attribute_name))
break MISSING_BLOCK_LABEL_201;
will_be_read_list.add(attribute_name);
List listeners_ref = listeners_cow.getList();
for (int i = 0; i < listeners_ref.size(); i++)
try
{
((DownloadManagerStateListener)listeners_ref.get(i)).stateChanged(this, new DownloadManagerStateEvent() {
final String val$attribute_name;
final DownloadManagerStateImpl this$0;
public int getType()
{
return 2;
}
public Object getData()
{
return attribute_name;
}
{
this$0 = DownloadManagerStateImpl.this;
attribute_name = s;
super();
}
});
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
listeners_ref = null;
CopyOnWriteList read_listeners = null;
read_listeners = (CopyOnWriteList)listeners_read_map_cow.get(attribute_name);
if (read_listeners != null)
listeners_ref = read_listeners.getList();
if (listeners_ref != null)
{
for (int i = 0; i < listeners_ref.si
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -