mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 02:57:35 -05:00
Updated aliases to better support wildcards and regular expressions
This commit is contained in:
@@ -79,9 +79,11 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
private HashMap<Integer,Alias> mUniqueID = new HashMap<Integer,Alias>();
|
private HashMap<Integer,Alias> mUniqueID = new HashMap<Integer,Alias>();
|
||||||
|
|
||||||
private boolean mESNWildcard = false;
|
private boolean mESNWildcard = false;
|
||||||
|
private boolean mMobileIDWildcard = false;
|
||||||
private boolean mFleetsyncWildcard = false;
|
private boolean mFleetsyncWildcard = false;
|
||||||
private boolean mMDC1200Wildcard = false;
|
private boolean mMDC1200Wildcard = false;
|
||||||
private boolean mMPT1327Wildcard = false;
|
private boolean mMPT1327Wildcard = false;
|
||||||
|
private boolean mSiteWildcard = false;
|
||||||
private boolean mTalkgroupWildcard = false;
|
private boolean mTalkgroupWildcard = false;
|
||||||
|
|
||||||
public AliasList()
|
public AliasList()
|
||||||
@@ -125,8 +127,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
{
|
{
|
||||||
mESNWildcard = true;
|
mESNWildcard = true;
|
||||||
|
|
||||||
//Replace (*) wildcard with regex wildcard (.)
|
mESN.put( fixWildcard( esn.getEsn() ), alias );
|
||||||
mESN.put( esn.getEsn().replace( "*", "." ), alias );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -140,8 +141,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
{
|
{
|
||||||
mFleetsyncWildcard = true;
|
mFleetsyncWildcard = true;
|
||||||
|
|
||||||
//Replace (*) wildcard with regex wildcard (.)
|
mFleetsync.put( fixWildcard( fs.getIdent() ), alias );
|
||||||
mFleetsync.put( fs.getIdent().replace( "*", "." ), alias );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -156,7 +156,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
mMDC1200Wildcard = true;
|
mMDC1200Wildcard = true;
|
||||||
|
|
||||||
//Replace (*) wildcard with regex wildcard (.)
|
//Replace (*) wildcard with regex wildcard (.)
|
||||||
mMDC1200.put( mdc.getIdent().replace( "*", "." ), alias );
|
mMDC1200.put( fixWildcard( mdc.getIdent() ), alias );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -175,7 +175,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
mMPT1327Wildcard = true;
|
mMPT1327Wildcard = true;
|
||||||
|
|
||||||
//Replace (*) wildcard with regex wildcard (.)
|
//Replace (*) wildcard with regex wildcard (.)
|
||||||
mMPT1327.put( ident.replace( "*", "." ), alias );
|
mMPT1327.put( fixWildcard( ident ), alias );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -185,14 +185,35 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
break;
|
break;
|
||||||
case MIN:
|
case MIN:
|
||||||
Min min = (Min)id;
|
Min min = (Min)id;
|
||||||
mMobileID.put( min.getMin(), alias );
|
|
||||||
|
if( min.getMin().contains( "*" ) )
|
||||||
|
{
|
||||||
|
mMobileIDWildcard = true;
|
||||||
|
mMobileID.put( fixWildcard( min.getMin() ), alias );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMobileID.put( min.getMin(), alias );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LTRNetUID:
|
case LTRNetUID:
|
||||||
UniqueID uid = (UniqueID)id;
|
UniqueID uid = (UniqueID)id;
|
||||||
|
|
||||||
mUniqueID.put( uid.getUid(), alias );
|
mUniqueID.put( uid.getUid(), alias );
|
||||||
break;
|
break;
|
||||||
case Site:
|
case Site:
|
||||||
mSiteID.put( ((SiteID)id).getSite(), alias );
|
SiteID siteID = (SiteID)id;
|
||||||
|
|
||||||
|
if( siteID.getSite().contains( "*" ) )
|
||||||
|
{
|
||||||
|
mSiteWildcard = true;
|
||||||
|
mSiteID.put( fixWildcard( siteID.getSite() ), alias );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mSiteID.put( siteID.getSite(), alias );
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Status:
|
case Status:
|
||||||
mStatus.put( ((StatusID)id).getStatus(), alias );
|
mStatus.put( ((StatusID)id).getStatus(), alias );
|
||||||
@@ -205,8 +226,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
mTalkgroupWildcard = true;
|
mTalkgroupWildcard = true;
|
||||||
|
|
||||||
//Replace (*) wildcard with regex wildcard (.)
|
//Replace (*) wildcard with regex wildcard (.)
|
||||||
mTalkgroup.put( tgid.getTalkgroup()
|
mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias );
|
||||||
.replace( "*", "." ), alias );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -219,9 +239,41 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts user wildcard character (*) to regex single character wildcard (.)
|
||||||
|
* but ignores a regex multi-character wildcard (.*)
|
||||||
|
*/
|
||||||
|
private String fixWildcard( String value )
|
||||||
|
{
|
||||||
|
if( value.contains( "*" ) && !value.contains( ".*" ) )
|
||||||
|
{
|
||||||
|
return value.replace( "*", "." );
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public Alias getSiteID( String siteID )
|
public Alias getSiteID( String siteID )
|
||||||
{
|
{
|
||||||
return mSiteID.get( siteID );
|
if( siteID != null )
|
||||||
|
{
|
||||||
|
if( mSiteWildcard )
|
||||||
|
{
|
||||||
|
for( String regex: mSiteID.keySet() )
|
||||||
|
{
|
||||||
|
if( siteID.matches( regex ) )
|
||||||
|
{
|
||||||
|
return mSiteID.get( regex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mSiteID.get( siteID );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alias getStatus( int status )
|
public Alias getStatus( int status )
|
||||||
@@ -242,11 +294,11 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
|
|
||||||
if( mESNWildcard )
|
if( mESNWildcard )
|
||||||
{
|
{
|
||||||
for( String key: mESN.keySet() )
|
for( String regex: mESN.keySet() )
|
||||||
{
|
{
|
||||||
if( esn.matches( key ) )
|
if( esn.matches( regex ) )
|
||||||
{
|
{
|
||||||
return mESN.get( key );
|
return mESN.get( regex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,11 +320,11 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
|
|
||||||
if( mFleetsyncWildcard )
|
if( mFleetsyncWildcard )
|
||||||
{
|
{
|
||||||
for( String key: mFleetsync.keySet() )
|
for( String regex: mFleetsync.keySet() )
|
||||||
{
|
{
|
||||||
if( ident.matches( key ) )
|
if( ident.matches( regex ) )
|
||||||
{
|
{
|
||||||
return mFleetsync.get( key );
|
return mFleetsync.get( regex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,11 +345,11 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
|
|
||||||
if( mMDC1200Wildcard )
|
if( mMDC1200Wildcard )
|
||||||
{
|
{
|
||||||
for( String key: mMDC1200.keySet() )
|
for( String regex: mMDC1200.keySet() )
|
||||||
{
|
{
|
||||||
if( ident.matches( key ) )
|
if( ident.matches( regex ) )
|
||||||
{
|
{
|
||||||
return mMDC1200.get( key );
|
return mMDC1200.get( regex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,15 +366,13 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
{
|
{
|
||||||
if( ident != null )
|
if( ident != null )
|
||||||
{
|
{
|
||||||
Alias retVal = null;
|
|
||||||
|
|
||||||
if( mMPT1327Wildcard )
|
if( mMPT1327Wildcard )
|
||||||
{
|
{
|
||||||
for( String key: mMPT1327.keySet() )
|
for( String regex: mMPT1327.keySet() )
|
||||||
{
|
{
|
||||||
if( ident.matches( key ) )
|
if( ident.matches( regex ) )
|
||||||
{
|
{
|
||||||
return mMPT1327.get( key );
|
return mMPT1327.get( regex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +391,7 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
{
|
{
|
||||||
for( Group group: mGroups )
|
for( Group group: mGroups )
|
||||||
{
|
{
|
||||||
if( group.contians( alias ) )
|
if( group.contains( alias ) )
|
||||||
{
|
{
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
@@ -353,22 +403,38 @@ public class AliasList implements Comparable<AliasList>
|
|||||||
|
|
||||||
public Alias getMobileIDNumberAlias( String ident )
|
public Alias getMobileIDNumberAlias( String ident )
|
||||||
{
|
{
|
||||||
return mMobileID.get( ident );
|
if( ident != null )
|
||||||
|
{
|
||||||
|
if( mMobileIDWildcard )
|
||||||
|
{
|
||||||
|
for( String regex: mMobileID.keySet() )
|
||||||
|
{
|
||||||
|
if( ident.matches( regex ) )
|
||||||
|
{
|
||||||
|
return mMobileID.get( regex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mMobileID.get( ident );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alias getTalkgroupAlias( String tgid )
|
public Alias getTalkgroupAlias( String tgid )
|
||||||
{
|
{
|
||||||
if( tgid != null )
|
if( tgid != null )
|
||||||
{
|
{
|
||||||
Alias retVal = null;
|
|
||||||
|
|
||||||
if( mTalkgroupWildcard )
|
if( mTalkgroupWildcard )
|
||||||
{
|
{
|
||||||
for( String key: mTalkgroup.keySet() )
|
for( String regex: mTalkgroup.keySet() )
|
||||||
{
|
{
|
||||||
if( tgid.matches( key ) )
|
if( tgid.matches( regex ) )
|
||||||
{
|
{
|
||||||
return mTalkgroup.get( key );
|
return mTalkgroup.get( regex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Group
|
|||||||
mAliases.remove( alias );
|
mAliases.remove( alias );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contians( Alias alias )
|
public boolean contains( Alias alias )
|
||||||
{
|
{
|
||||||
return mAliases.contains( alias );
|
return mAliases.contains( alias );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,24 +33,27 @@ public class AliasActionManager implements Listener<Message>
|
|||||||
@Override
|
@Override
|
||||||
public void receive( Message message )
|
public void receive( Message message )
|
||||||
{
|
{
|
||||||
List<Alias> aliases = message.getAliases();
|
if( message.isValid() )
|
||||||
|
|
||||||
if( aliases != null )
|
|
||||||
{
|
{
|
||||||
for( Alias alias: aliases )
|
List<Alias> aliases = message.getAliases();
|
||||||
{
|
|
||||||
if( alias.hasActions() )
|
|
||||||
{
|
|
||||||
List<AliasAction> actions = alias.getAction();
|
|
||||||
|
|
||||||
for( AliasAction action: actions )
|
if( aliases != null )
|
||||||
|
{
|
||||||
|
for( Alias alias: aliases )
|
||||||
|
{
|
||||||
|
if( alias.hasActions() )
|
||||||
{
|
{
|
||||||
/* Provide access to the thread pool manager in case the
|
List<AliasAction> actions = alias.getAction();
|
||||||
* action needs to setup a timer, and provide the original
|
|
||||||
* message to be used as part of the action (e.g. sending
|
for( AliasAction action: actions )
|
||||||
* the message as a text message to a cell phone */
|
{
|
||||||
action.execute( mResourceManager.getThreadPoolManager(),
|
/* Provide access to the thread pool manager in case the
|
||||||
alias, message );
|
* action needs to setup a timer, and provide the original
|
||||||
|
* message to be used as part of the action (e.g. sending
|
||||||
|
* the message as a text message to a cell phone */
|
||||||
|
action.execute( mResourceManager.getThreadPoolManager(),
|
||||||
|
alias, message );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ public class ScriptAction extends RecurringAction
|
|||||||
{
|
{
|
||||||
if( mScript != null )
|
if( mScript != null )
|
||||||
{
|
{
|
||||||
mLog.debug( "Running Script ..." );
|
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder( mScript );
|
ProcessBuilder pb = new ProcessBuilder( mScript );
|
||||||
|
|
||||||
pb.redirectErrorStream( true );
|
pb.redirectErrorStream( true );
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class LJ1200Message extends Message
|
|||||||
|
|
||||||
public Alias getSiteIDAlias()
|
public Alias getSiteIDAlias()
|
||||||
{
|
{
|
||||||
if( mAliasList != null )
|
if( mAliasList != null && getFunction() == Function.F8_SITE_ID )
|
||||||
{
|
{
|
||||||
return mAliasList.getSiteID( getSiteID() );
|
return mAliasList.getSiteID( getSiteID() );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user